aboutsummaryrefslogtreecommitdiff
path: root/options.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2022-06-13 04:31:31 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2022-06-13 04:31:31 +0300
commit05626592208f56d88523887e2b80c0514f8ac210 (patch)
treeb0db34890e7366008754e975a8f28e878c5b28bf /options.go
initial
Diffstat (limited to 'options.go')
-rw-r--r--options.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/options.go b/options.go
new file mode 100644
index 0000000..591f552
--- /dev/null
+++ b/options.go
@@ -0,0 +1,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{}
+ }
+}