aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/grammar.ron2
-rw-r--r--src/parser/grammar/items/mod.rs18
-rw-r--r--src/syntax_kinds/generated.rs2
3 files changed, 21 insertions, 1 deletions
diff --git a/src/grammar.ron b/src/grammar.ron
index 9383abd19..a8c922040 100644
--- a/src/grammar.ron
+++ b/src/grammar.ron
@@ -146,7 +146,9 @@ Grammar(
146 "NAME_REF", 146 "NAME_REF",
147 "VALUE_PARAMETER", 147 "VALUE_PARAMETER",
148 "BLOCK", 148 "BLOCK",
149
149 "LET_STMT", 150 "LET_STMT",
151 "EXPR_STMT",
150 152
151 "TYPE_PARAM", 153 "TYPE_PARAM",
152 "LIFETIME_PARAM", 154 "LIFETIME_PARAM",
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index d059833a0..c88e39596 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -223,6 +223,11 @@ fn fn_item(p: &mut Parser) {
223 fn_ret_type(p); 223 fn_ret_type(p);
224 block(p); 224 block(p);
225 225
226 // test block
227 // fn a() {}
228 // fn b() { let _ = 1; }
229 // fn c() { 1; 2; }
230 // fn d() { 1; 2 }
226 fn block(p: &mut Parser) { 231 fn block(p: &mut Parser) {
227 if !p.at(L_CURLY) { 232 if !p.at(L_CURLY) {
228 p.error("expected block"); 233 p.error("expected block");
@@ -232,7 +237,18 @@ fn fn_item(p: &mut Parser) {
232 while !p.at(EOF) && !p.at(R_CURLY) { 237 while !p.at(EOF) && !p.at(R_CURLY) {
233 match p.current() { 238 match p.current() {
234 LET_KW => let_stmt(p), 239 LET_KW => let_stmt(p),
235 _ => p.err_and_bump("expected statement"), 240 _ => {
241 let expr_stmt = p.start();
242 expressions::expr(p);
243 if p.eat(SEMI) {
244 expr_stmt.complete(p, EXPR_STMT);
245 if p.at(R_CURLY) {
246 break;
247 }
248 } else {
249 expr_stmt.abandon(p);
250 }
251 }
236 } 252 }
237 } 253 }
238 p.expect(R_CURLY); 254 p.expect(R_CURLY);
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs
index dc391c4a7..c49ad9a59 100644
--- a/src/syntax_kinds/generated.rs
+++ b/src/syntax_kinds/generated.rs
@@ -137,6 +137,7 @@ pub enum SyntaxKind {
137 VALUE_PARAMETER, 137 VALUE_PARAMETER,
138 BLOCK, 138 BLOCK,
139 LET_STMT, 139 LET_STMT,
140 EXPR_STMT,
140 TYPE_PARAM, 141 TYPE_PARAM,
141 LIFETIME_PARAM, 142 LIFETIME_PARAM,
142 TYPE_PARAM_LIST, 143 TYPE_PARAM_LIST,
@@ -287,6 +288,7 @@ impl SyntaxKind {
287 VALUE_PARAMETER => &SyntaxInfo { name: "VALUE_PARAMETER" }, 288 VALUE_PARAMETER => &SyntaxInfo { name: "VALUE_PARAMETER" },
288 BLOCK => &SyntaxInfo { name: "BLOCK" }, 289 BLOCK => &SyntaxInfo { name: "BLOCK" },
289 LET_STMT => &SyntaxInfo { name: "LET_STMT" }, 290 LET_STMT => &SyntaxInfo { name: "LET_STMT" },
291 EXPR_STMT => &SyntaxInfo { name: "EXPR_STMT" },
290 TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" }, 292 TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" },
291 LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" }, 293 LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" },
292 TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" }, 294 TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" },