about summary refs log tree commit diff
path: root/src/comp/front/parser.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2011-06-08 03:58:52 -0400
committerJosh Matthews <josh@joshmatthews.net>2011-06-08 04:02:55 -0400
commit2235fb73ef990d3c19b2888feed69ddb462ab686 (patch)
tree93a49f2adb8b5c53a08cc4c2c7ad33baecc1e4e9 /src/comp/front/parser.rs
parentb5c73605ead0dc27eb09e5f5860326b2cf2c5cd1 (diff)
downloadrust-2235fb73ef990d3c19b2888feed69ddb462ab686.tar.gz
rust-2235fb73ef990d3c19b2888feed69ddb462ab686.zip
Add optional message to fail.
Diffstat (limited to 'src/comp/front/parser.rs')
-rw-r--r--src/comp/front/parser.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index b84a740a917..562bc0cc32e 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -256,7 +256,6 @@ fn parse_value_ident(&parser p) -> ast::ident {
     ret parse_ident(p);
 }
 
-
 /* FIXME: gross hack copied from rustboot to make certain configuration-based
  * decisions work at build-time.  We should probably change it to use a
  * lexical sytnax-extension or something similar. For now we just imitate
@@ -934,7 +933,17 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
         ex = expand_syntax_ext(p, ext_span, pth, es.node,
                                none[str]);
     } else if (eat_word(p, "fail")) {
-        ex = ast::expr_fail(p.get_ann());
+        auto msg;
+        alt (p.peek()) {
+           case (token::LIT_STR(?s)) {
+               msg = some[str](p.get_str(s));
+               p.bump();
+           }
+           case (_) {
+               msg = none[str];
+           }
+        }
+        ex = ast::expr_fail(p.get_ann(), msg);
     } else if (eat_word(p, "log")) {
         auto e = parse_expr(p);
         auto hi = e.span.hi;
@@ -1643,7 +1652,7 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
                 case (ast::expr_field(_,_,_))    { ret true; }
                 case (ast::expr_index(_,_,_))    { ret true; }
                 case (ast::expr_path(_,_))       { ret true; }
-                case (ast::expr_fail(_))         { ret true; }
+                case (ast::expr_fail(_,_))       { ret true; }
                 case (ast::expr_break(_))        { ret true; }
                 case (ast::expr_cont(_))         { ret true; }
                 case (ast::expr_ret(_,_))        { ret true; }