diff options
| author | Eric Holk <eric.holk@gmail.com> | 2012-07-05 12:10:33 -0700 |
|---|---|---|
| committer | Eric Holk <eric.holk@gmail.com> | 2012-07-06 10:42:40 -0700 |
| commit | 05cdda3a2c147fdc8caef4e6c662f518ec325e0a (patch) | |
| tree | fba957706d8588512bfd259d7873edd615854d36 /src/libsyntax/parse/parser.rs | |
| parent | a787f4001388a394d5219b74113a718d980e4c90 (diff) | |
| download | rust-05cdda3a2c147fdc8caef4e6c662f518ec325e0a.tar.gz rust-05cdda3a2c147fdc8caef4e6c662f518ec325e0a.zip | |
Plumbing and parsing for item-position macros.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8bac3e0d751..2f4fe783b49 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -9,7 +9,7 @@ import lexer::reader; import prec::{as_prec, token_to_binop}; import attr::parser_attr; import common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed, - seq_sep_none, token_to_str, parser_common}; + seq_sep_none, token_to_str}; import dvec::{dvec, extensions}; import vec::{push}; import ast::*; @@ -2595,6 +2595,21 @@ class parser { self.parse_item_impl() } else if self.eat_keyword("class") { self.parse_item_class() + } else if !self.is_any_keyword(copy self.token) + && self.look_ahead(1) == token::NOT + { + // 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 m: ast::mac = {node: m, + span: {lo: self.span.lo, + hi: self.span.hi, + expn_info: none}}; + (id, item_mac(m), none) } else { ret none; }; some(self.mk_item(lo, self.last_span.hi, ident, item_, vis, alt extra_attrs { |
