lexpr/options.go

30 lines
528 B
Go
Raw Normal View History

2022-06-13 04:31:31 +03:00
package lexpr
type Opt func(*Lexpr)
func WithOperators(operators map[string]Operator) Opt {
return func(l *Lexpr) {
l.operators = operators
}
}
func WithFunctions(functions map[string]func(ts *TokenStack) error) Opt {
return func(l *Lexpr) {
l.functions = functions
}
}
func WithValues(variables map[string]any) Opt {
return func(l *Lexpr) {
l.variables = variables
}
}
func WithDefaults() Opt {
return func(l *Lexpr) {
l.operators = Operators
l.functions = Functions
l.variables = map[string]any{}
}
}