diff options
| author | Kevin Atkinson <kevina@cs.utah.edu> | 2012-01-31 23:50:12 -0700 |
|---|---|---|
| committer | Kevin Atkinson <kevina@cs.utah.edu> | 2012-02-03 20:41:48 -0700 |
| commit | 5ea04c65c151708272b92d00c8448156239affb2 (patch) | |
| tree | ea37e5cb51bb04e9c7c20d01d080865ac12a4255 /src/comp/syntax/parse | |
| parent | e76fdeb3a6411f151aafb6a48df26bc6c8f977a5 (diff) | |
| download | rust-5ea04c65c151708272b92d00c8448156239affb2.tar.gz rust-5ea04c65c151708272b92d00c8448156239affb2.zip | |
Add support for recognizing macro body, completely untested.
Diffstat (limited to 'src/comp/syntax/parse')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index ecbae8a1fc2..ae00c9fbce7 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -993,7 +993,24 @@ fn parse_syntax_ext_naked(p: parser, lo: uint) -> @ast::expr { }; let hi = es.span.hi; let e = mk_expr(p, es.span.lo, hi, ast::expr_vec(es.node, ast::imm)); - ret mk_mac_expr(p, lo, hi, ast::mac_invoc(pth, e, none)); + let b = none; + if p.token == token::LBRACE { + p.bump(); + let lo = p.span.lo; + let depth = 1u; + while (depth > 0u) { + alt (p.token) { + token::LBRACE {depth += 1u;} + token::RBRACE {depth -= 1u;} + token::EOF {p.fatal("unexpected EOF in macro body");} + _ {} + } + p.bump(); + } + let hi = p.last_span.hi; + b = some({span: mk_sp(lo,hi)}); + } + ret mk_mac_expr(p, lo, p.span.hi, ast::mac_invoc(pth, e, b)); } fn parse_dot_or_call_expr(p: parser) -> pexpr { |
