-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgal.go
More file actions
34 lines (29 loc) · 1014 Bytes
/
gal.go
File metadata and controls
34 lines (29 loc) · 1014 Bytes
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
30
31
32
33
34
package gal
type exprType int
const (
unknownType exprType = iota
blankType
numericalType
operatorType
stringType
boolType
variableType
functionType
objectPropertyType // "cousin" of a variableType, but for a property of a user-defined object
objectMethodType // "cousin" of a functionType, but for a method of a user-defined object
objectAccessorByPropertyType // represents an object accessor of a "left hand side" expression by property
objectAccessorByMethodType // represents an object accessor of a "left hand side" expression by method
)
// Example: Parse("blah").Eval(WithVariables(...), WithFunctions(...), WithObjects(...))
// This allows to parse an expression and then use the resulting Tree for multiple
// evaluations with different variables provided.
func Parse(expr string) Tree {
treeBuilder := NewTreeBuilder()
tree, err := treeBuilder.FromExpr(expr)
if err != nil {
return Tree{
NewUndefinedWithReasonf("%s", err.Error()),
}
}
return tree
}