|
|
@@ -17,22 +17,28 @@ module.exports = class Parser {
|
|
17
|
17
|
expr() {
|
|
18
|
18
|
this.tokenStream.eat(tokenTypes.OPAREN)
|
|
19
|
19
|
|
|
20
|
|
- let functionCallNode = new Node()
|
|
21
|
|
- functionCallNode.functionName = this.tokenStream.eat(tokenTypes.LITERAL).value
|
|
22
|
|
- functionCallNode.args = []
|
|
23
|
|
- functionCallNode.subtree = []
|
|
|
20
|
+ let elementNode = new Node()
|
|
|
21
|
+ elementNode.type = 'functionCall'
|
|
|
22
|
+ elementNode.functionName = this.tokenStream.eat(tokenTypes.LITERAL).value
|
|
|
23
|
+ elementNode.args = []
|
|
|
24
|
+ elementNode.subtree = []
|
|
24
|
25
|
|
|
25
|
26
|
while (this.tokenStream.peek().type != tokenTypes.CPAREN && this.tokenStream.peek().type !== tokenTypes.EOF) {
|
|
26
|
27
|
if (this.tokenStream.peek().type === tokenTypes.ATTRIBUTE) {
|
|
27
|
|
- functionCallNode.args.push(this.attribute())
|
|
|
28
|
+ elementNode.args.push(this.attribute())
|
|
28
|
29
|
} else if (this.tokenStream.peek().type === tokenTypes.OPAREN) {
|
|
29
|
|
- functionCallNode.subtree.push(this.expr())
|
|
|
30
|
+ elementNode.subtree.push(this.expr())
|
|
|
31
|
+ } else if (this.tokenStream.peek().type === tokenTypes.QUOTE) {
|
|
|
32
|
+ elementNode.subtree.push(new Node({
|
|
|
33
|
+ type: 'text',
|
|
|
34
|
+ content: this.string()
|
|
|
35
|
+ }))
|
|
30
|
36
|
}
|
|
31
|
37
|
}
|
|
32
|
38
|
|
|
33
|
39
|
this.tokenStream.eat(tokenTypes.CPAREN)
|
|
34
|
40
|
|
|
35
|
|
- return functionCallNode
|
|
|
41
|
+ return elementNode
|
|
36
|
42
|
}
|
|
37
|
43
|
|
|
38
|
44
|
attribute() {
|