about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorPaul Stansifer <paul.stansifer@gmail.com>2012-07-06 14:48:01 -0700
committerPaul Stansifer <paul.stansifer@gmail.com>2012-07-09 17:44:46 -0700
commitcaa83b41bba2b63c8b55193d176d40f5eb0fa9a8 (patch)
tree050763eab3982b739251cda7ca3c404c9dd8542e /src/libsyntax/parse
parentcabee6391d599be867b80f81de219d9f982585f5 (diff)
downloadrust-caa83b41bba2b63c8b55193d176d40f5eb0fa9a8.tar.gz
rust-caa83b41bba2b63c8b55193d176d40f5eb0fa9a8.zip
Add support for matchers nonterminals.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs12
-rw-r--r--src/libsyntax/parse/token.rs10
2 files changed, 12 insertions, 10 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 882957ade5b..a2d0ad33afc 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1249,13 +1249,17 @@ class parser {
         };
     }
 
+    fn parse_matchers() -> ~[matcher] {
+        let name_idx = @mut 0u;
+        ret self.parse_seq(token::LBRACE, token::RBRACE,
+                           common::seq_sep_none(),
+                           |p| p.parse_matcher(name_idx)).node;
+    }
+
     /* temporary */
     fn parse_tt_mac_demo() -> @expr {
         import ext::tt::earley_parser::{parse,success,failure};
-        let name_idx = @mut 0u;
-        let ms = self.parse_seq(token::LBRACE, token::RBRACE,
-                                common::seq_sep_none(),
-                                |p| p.parse_matcher(name_idx)).node;
+        let ms = self.parse_matchers();
         self.quote_depth += 1u;
         let tt_rhs= self.parse_token_tree();
         self.quote_depth -= 1u;
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 6416fafd6ad..a0abec5c437 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -96,10 +96,8 @@ enum whole_nt {
     w_ty(  @ast::ty),
     w_ident(str_num, bool),
     w_path(@ast::path),
-    // TODO: this seems to cause infinite recursion in
-    // type_structually_contains if it's not an @-box. We should at least get
-    // failure instead.
-    w_tt(@ast::token_tree),
+    w_tt(  @ast::token_tree), //needs @ed to break a circularity
+    w_mtcs(~[ast::matcher])
 }
 
 fn binop_to_str(o: binop) -> str {
@@ -193,8 +191,8 @@ fn to_str(in: interner<@str>, t: token) -> str {
               w_stmt(*) { "statement" } w_pat(*) { "pattern" }
               w_expr(*) { "expression" } w_ty(*) { "type" }
               w_ident(*) { "identifier" } w_path(*) { "path" }
-              w_tt(*) { "tt" }
-        }
+              w_tt(*) { "tt" } w_mtcs(*) { "matcher sequence" }
+            }
       }
     }
 }