format/mutator.go

32 lines
524 B
Go
Raw Normal View History

2022-04-18 17:39:41 +02:00
package main
type NumMutator struct {
Op NumOperator
Var bool
Value int
}
type NumOperator string
const (
NumOperatorAdd NumOperator = "+"
NumOperatorSub NumOperator = "-"
NumOperatorMul NumOperator = "*"
NumOperatorDiv NumOperator = "/"
)
func NewNumOperatorFromString(str string) NumOperator {
switch str {
case "+":
return NumOperatorAdd
case "-":
return NumOperatorSub
case "*":
return NumOperatorMul
case "/":
return NumOperatorDiv
default:
panic("invalid number operator: " + str)
}
}