about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorPaul Stansifer <paul.stansifer@gmail.com>2012-11-19 00:36:26 -0500
committerGraydon Hoare <graydon@mozilla.com>2012-11-29 12:09:10 -0800
commite77491bd870d9b026ebfbda07caab103f111ce8f (patch)
treea36388ace408393ef3994fc1a1b89641e58cdc31 /src/libsyntax/parse
parentbd92499c5e65248b3dd2078e2f428f33004cba3d (diff)
downloadrust-e77491bd870d9b026ebfbda07caab103f111ce8f.tar.gz
rust-e77491bd870d9b026ebfbda07caab103f111ce8f.zip
Make the parser handle stmt macros that might be exprs at the end of blocks.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 3beef2d3eb2..b548695d187 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2380,6 +2380,25 @@ impl Parser {
                             }
                         }
 
+                        stmt_mac(m) => {
+                            // Statement macro; might be an expr
+                            match self.token {
+                                token::SEMI => {
+                                    self.bump();
+                                    stmts.push(stmt);
+                                }
+                                token::RBRACE => {
+                                    // if a block ends in `m!(arg)` without
+                                    // a `;`, it must be an expr
+                                    expr = Some(
+                                        self.mk_mac_expr(stmt.span.lo,
+                                                         stmt.span.hi,
+                                                         m.node));
+                                }
+                                _ => { stmts.push(stmt); }
+                            }
+                        }
+
                         _ => { // All other kinds of statements:
                             stmts.push(stmt);
 
@@ -3567,6 +3586,10 @@ impl Parser {
             // item macro.
             let pth = self.parse_path_without_tps();
             self.expect(token::NOT);
+
+            // a 'special' identifier (like what `macro_rules!` uses)
+            // is optional. We should eventually unify invoc syntax
+            // and remove this.
             let id = if self.token == token::LPAREN {
                 token::special_idents::invalid // no special identifier
             } else {