aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-07-31 13:33:51 +0100
committerAleksey Kladov <[email protected]>2018-07-31 13:33:51 +0100
commitf843f23abae72ba3bd2920edc2a8635eafb61409 (patch)
tree34590d26e6c1c510013c103a1787f01e47cf03c7 /src/parser/grammar
parent580340d1b879a434302d314ef6cd9f4cae0cd57d (diff)
Type ascription in let
Diffstat (limited to 'src/parser/grammar')
-rw-r--r--src/parser/grammar/items/mod.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index 73fd5235a..00c52dc09 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -267,13 +267,24 @@ fn fn_item(p: &mut Parser) {
267 m.complete(p, BLOCK); 267 m.complete(p, BLOCK);
268 } 268 }
269 269
270 // test let_stmt;
271 // fn foo() {
272 // let a;
273 // let b: i32;
274 // let c = 92;
275 // let d: i32 = 92;
276 // }
270 fn let_stmt(p: &mut Parser) { 277 fn let_stmt(p: &mut Parser) {
271 assert!(p.at(LET_KW)); 278 assert!(p.at(LET_KW));
272 let m = p.start(); 279 let m = p.start();
273 p.bump(); 280 p.bump();
274 patterns::pattern(p); 281 patterns::pattern(p);
275 p.expect(EQ); 282 if p.eat(COLON) {
276 expressions::expr(p); 283 types::type_(p);
284 }
285 if p.eat(EQ) {
286 expressions::expr(p);
287 }
277 p.expect(SEMI); 288 p.expect(SEMI);
278 m.complete(p, LET_STMT); 289 m.complete(p, LET_STMT);
279 } 290 }