|
@@ -57,6 +57,9 @@ module.exports = class Parser {
|
57
|
57
|
} else if (this.tokenStream.peek().value === 'if') {
|
58
|
58
|
this.tokenStream.eat(tokenTypes.IDENTIFIER)
|
59
|
59
|
node = this.conditional()
|
|
60
|
+ } else if (this.tokenStream.peek().value === 'let') {
|
|
61
|
+ this.tokenStream.eat(tokenTypes.IDENTIFIER)
|
|
62
|
+ node = this.let()
|
60
|
63
|
} else {
|
61
|
64
|
node = new AST.Application()
|
62
|
65
|
|
|
@@ -129,6 +132,28 @@ module.exports = class Parser {
|
129
|
132
|
})
|
130
|
133
|
}
|
131
|
134
|
|
|
135
|
+ let() {
|
|
136
|
+ let bindings = []
|
|
137
|
+
|
|
138
|
+ this.tokenStream.eat(tokenTypes.OPAREN)
|
|
139
|
+
|
|
140
|
+ while (this.tokenStream.peek().type !== tokenTypes.CPAREN) {
|
|
141
|
+ this.tokenStream.eat(tokenTypes.OPAREN)
|
|
142
|
+ bindings.push({
|
|
143
|
+ key: new AST.Identifier({
|
|
144
|
+ name: this.tokenStream.eat(tokenTypes.IDENTIFIER).value,
|
|
145
|
+ }),
|
|
146
|
+ value: this.expr(),
|
|
147
|
+ })
|
|
148
|
+ this.tokenStream.eat(tokenTypes.CPAREN)
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ this.tokenStream.eat(tokenTypes.CPAREN)
|
|
152
|
+
|
|
153
|
+ return new AST.LetBinding({
|
|
154
|
+ bindings: bindings,
|
|
155
|
+ body: this.expr(),
|
|
156
|
+ })
|
132
|
157
|
}
|
133
|
158
|
|
134
|
159
|
number() {
|