format/mutator.go
2022-04-18 17:39:41 +02:00

32 lines
524 B
Go

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)
}
}