aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar/items
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-17 22:06:48 +0000
committerAleksey Kladov <[email protected]>2018-02-17 22:06:48 +0000
commitc6f4a06b4297f498da4bc2cd747aa38effb855b0 (patch)
treea383a2e71da6029bbd6a5669b5f9d2b99a1b0a92 /src/parser/grammar/items
parent8c4c5b5b802a204bfeef52e215358ae838900f1f (diff)
G: value_parameters, patterns & let statement
Diffstat (limited to 'src/parser/grammar/items')
-rw-r--r--src/parser/grammar/items/mod.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index 3af6d13a1..1fe646652 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -218,9 +218,33 @@ fn fn_item(p: &mut Parser) {
218 p.error("expected function arguments"); 218 p.error("expected function arguments");
219 } 219 }
220 220
221 if p.at(L_CURLY) { 221 block(p);
222 p.expect(L_CURLY); 222
223 fn block(p: &mut Parser) {
224 if !p.at(L_CURLY) {
225 p.error("expected block");
226 }
227 let m = p.start();
228 p.bump();
229 while !p.at(EOF) && !p.at(R_CURLY) {
230 match p.current() {
231 LET_KW => let_stmt(p),
232 _ => p.err_and_bump("expected statement"),
233 }
234 }
223 p.expect(R_CURLY); 235 p.expect(R_CURLY);
236 m.complete(p, BLOCK);
237 }
238
239 fn let_stmt(p: &mut Parser) {
240 assert!(p.at(LET_KW));
241 let m = p.start();
242 p.bump();
243 patterns::pattern(p);
244 p.expect(EQ);
245 expressions::expr(p);
246 p.expect(SEMI);
247 m.complete(p, LET_STMT);
224 } 248 }
225} 249}
226 250