forked from expr-lang/expr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.go
69 lines (54 loc) · 830 Bytes
/
node.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package expr
import (
"regexp"
)
// Node represents items of abstract syntax tree.
type Node interface {
Eval(env interface{}) (interface{}, error)
}
type nilNode struct{}
type identifierNode struct {
value string
}
type numberNode struct {
value float64
}
type boolNode struct {
value bool
}
type textNode struct {
value string
}
type nameNode struct {
name string
}
type unaryNode struct {
operator string
node Node
}
type binaryNode struct {
operator string
left Node
right Node
}
type matchesNode struct {
r *regexp.Regexp
left Node
right Node
}
type builtinNode struct {
name string
arguments []Node
}
type functionNode struct {
name string
arguments []Node
}
type conditionalNode struct {
cond Node
exp1 Node
exp2 Node
}
type arrayNode struct {
nodes []Node
}