diff options
| author | Paul Stansifer <paul.stansifer@gmail.com> | 2012-07-06 18:04:28 -0700 |
|---|---|---|
| committer | Paul Stansifer <paul.stansifer@gmail.com> | 2012-07-09 17:44:46 -0700 |
| commit | 54741b9427541df4508a3a7423102a677ba3dce9 (patch) | |
| tree | 59e443febfea46a250d7b1672fa3505f2d3eedfd /src/libsyntax/parse/parser.rs | |
| parent | caa83b41bba2b63c8b55193d176d40f5eb0fa9a8 (diff) | |
| download | rust-54741b9427541df4508a3a7423102a677ba3dce9.tar.gz rust-54741b9427541df4508a3a7423102a677ba3dce9.zip | |
Allow defining token tree macros. They should work now!
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a2d0ad33afc..b800dc7fda3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1022,9 +1022,12 @@ class parser { /* `!`, as an operator, is prefix, so we know this isn't that */ if self.token == token::NOT { self.bump(); - let m_body = self.parse_token_tree(); + let tts = self.parse_unspanned_seq( + token::LBRACE, token::RBRACE, seq_sep_none(), + |p| p.parse_token_tree()); let hi = self.span.hi; - ret pexpr(self.mk_mac_expr(lo, hi, mac_invoc_tt(pth,m_body))); + + ret pexpr(self.mk_mac_expr(lo, hi, mac_invoc_tt(pth, tts))); } else { hi = pth.span.hi; ex = expr_path(pth); @@ -2642,14 +2645,17 @@ class parser { self.parse_item_class() } else if !self.is_any_keyword(copy self.token) && self.look_ahead(1) == token::NOT + && is_plain_ident(self.look_ahead(2)) { // item macro. let pth = self.parse_path_without_tps(); #error("parsing invocation of %s", *pth.idents[0]); self.expect(token::NOT); let id = self.parse_ident(); - let tt = self.parse_token_tree(); - let m = ast::mac_invoc_tt(pth, tt); + let tts = self.parse_unspanned_seq(token::LBRACE, token::RBRACE, + seq_sep_none(), + |p| p.parse_token_tree()); + let m = ast::mac_invoc_tt(pth, tts); let m: ast::mac = {node: m, span: {lo: self.span.lo, hi: self.span.hi, |
