aboutsummaryrefslogtreecommitdiff
path: root/options.go
blob: 591f552992a678cd5159ba553ce81e5ceca94fd8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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{}
	}
}