about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-02-15 09:35:11 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-02-15 11:53:32 +0100
commit6627890f6bcbf2a2b71229572023cfaec91ab805 (patch)
tree3671e2228ce7bc502f472f4e6d3f05e7804686f3 /src/comp/syntax/parse
parent9f95ccb4269f2bb795c56d0fa7692cb7705c608e (diff)
downloadrust-6627890f6bcbf2a2b71229572023cfaec91ab805.tar.gz
rust-6627890f6bcbf2a2b71229572023cfaec91ab805.zip
Support 'alt check' syntax
It is only a way to flag an alt as intentionally non-exhaustive right now.

Issue #1679
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/parser.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index ad6b47858bc..01f04433908 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1372,6 +1372,8 @@ fn parse_do_while_expr(p: parser) -> @ast::expr {
 
 fn parse_alt_expr(p: parser) -> @ast::expr {
     let lo = p.last_span.lo;
+    let mode = if eat_word(p, "check") { ast::alt_check }
+               else { ast::alt_exhaustive };
     let discriminant = parse_expr(p);
     expect(p, token::LBRACE);
     let arms: [ast::arm] = [];
@@ -1384,7 +1386,7 @@ fn parse_alt_expr(p: parser) -> @ast::expr {
     }
     let hi = p.span.hi;
     p.bump();
-    ret mk_expr(p, lo, hi, ast::expr_alt(discriminant, arms));
+    ret mk_expr(p, lo, hi, ast::expr_alt(discriminant, arms, mode));
 }
 
 fn parse_expr(p: parser) -> @ast::expr {
@@ -1653,7 +1655,7 @@ fn expr_is_complete(p: parser, e: pexpr) -> bool {
 fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool {
     alt e.node {
       ast::expr_if(_, _, _) | ast::expr_if_check(_, _, _)
-      | ast::expr_alt(_, _) | ast::expr_block(_)
+      | ast::expr_alt(_, _, _) | ast::expr_block(_)
       | ast::expr_do_while(_, _) | ast::expr_while(_, _)
       | ast::expr_for(_, _, _)
       | ast::expr_call(_, _, true) {