Skip to content

Commit cfcf737

Browse files
committed
Add parser
1 parent 57998c1 commit cfcf737

File tree

3 files changed

+774
-0
lines changed

3 files changed

+774
-0
lines changed

node.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package expr
2+
3+
// Node items of abstract syntax tree.
4+
type Node interface{}
5+
6+
type nilNode struct{}
7+
8+
type identifierNode struct {
9+
value string
10+
}
11+
12+
type numberNode struct {
13+
value float64
14+
}
15+
16+
type boolNode struct {
17+
value bool
18+
}
19+
20+
type textNode struct {
21+
value string
22+
}
23+
24+
type nameNode struct {
25+
name string
26+
}
27+
28+
type unaryNode struct {
29+
operator string
30+
node Node
31+
}
32+
33+
type binaryNode struct {
34+
operator string
35+
left Node
36+
right Node
37+
}
38+
39+
type propertyNode struct {
40+
node Node
41+
property Node
42+
}
43+
44+
type methodNode struct {
45+
node Node
46+
property identifierNode
47+
arguments []Node
48+
}
49+
50+
type functionNode struct {
51+
name string
52+
arguments []Node
53+
}
54+
55+
type conditionalNode struct {
56+
cond Node
57+
exp1 Node
58+
exp2 Node
59+
}
60+
61+
type arrayNode struct {
62+
nodes []Node
63+
}
64+
65+
type mapNode struct {
66+
pairs []pairNode
67+
}
68+
69+
type pairNode struct {
70+
key Node
71+
value Node
72+
}

0 commit comments

Comments
 (0)