forked from tordarus/format
introduced mutators
This commit is contained in:
31
mutator.go
Normal file
31
mutator.go
Normal file
@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user