about summary refs log tree commit diff
path: root/src/comp/syntax/parse/parser.rs
diff options
context:
space:
mode:
authorPaul Stansifer <paul.stansifer@gmail.com>2011-06-29 18:07:04 -0700
committerPaul Stansifer <paul.stansifer@gmail.com>2011-07-11 18:52:10 -0700
commit80cf4ecd3bfe602004145e57cf7fdfb067b76ce1 (patch)
tree7fe2ceabdf59e39be101924ee18d6afdefcd00b5 /src/comp/syntax/parse/parser.rs
parentfd24fd5e318c5bfbe0cba49f0b49edd3c112f451 (diff)
downloadrust-80cf4ecd3bfe602004145e57cf7fdfb067b76ce1.tar.gz
rust-80cf4ecd3bfe602004145e57cf7fdfb067b76ce1.zip
Add nodes for embedding types and blocks in expressions for macros.
Diffstat (limited to 'src/comp/syntax/parse/parser.rs')
-rw-r--r--src/comp/syntax/parse/parser.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 59b0884704c..7d6fc8561cc 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -804,6 +804,13 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
             parse_seq_to_end_ivec(token::RBRACKET, some(token::COMMA),
                                   parse_expr, p);
         ex = ast::expr_vec(es, mut, ast::sk_rc);
+    } else if (p.peek() == token::POUND_LT) {
+        p.bump();
+        ex = ast::expr_embeded_type(parse_ty(p));
+        expect(p, token::GT);
+    } else if (p.peek() == token::POUND_LBRACE) {
+        p.bump();
+        ex = ast::expr_embeded_block(parse_block_tail(p));
     } else if (p.peek() == token::TILDE) {
         p.bump();
         alt (p.peek()) {
@@ -1715,10 +1722,15 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
 }
 
 fn parse_block(&parser p) -> ast::block {
+    expect(p, token::LBRACE);
+    be parse_block_tail(p);
+}
+
+// some blocks start with "#{"... 
+fn parse_block_tail(&parser p) -> ast::block {
     auto lo = p.get_lo_pos();
     let (@ast::stmt)[] stmts = ~[];
     let option::t[@ast::expr] expr = none;
-    expect(p, token::LBRACE);
     while (p.peek() != token::RBRACE) {
         alt (p.peek()) {
             case (token::SEMI) {
@@ -2204,8 +2216,10 @@ fn parse_outer_attrs_or_ext(&parser p) -> attr_or_ext {
         if (p.peek() == token::LBRACKET) {
             auto first_attr = parse_attribute_naked(p, ast::attr_outer, lo);
             ret some(left(~[first_attr] + parse_outer_attributes(p)));
-        } else {
+        } else if (! (p.peek() == token::LT || p.peek() == token::LBRACKET)) {
             ret some(right(parse_syntax_ext_naked(p, lo)));
+        } else {
+            ret none;
         }
     } else {
         ret none;