diff options
| author | Kevin Atkinson <kevina@cs.utah.edu> | 2012-01-25 16:38:09 -0700 |
|---|---|---|
| committer | Kevin Atkinson <kevina@cs.utah.edu> | 2012-02-03 20:23:49 -0700 |
| commit | 5ef53382aeac2de7e6dcc43c156312d2e68c15e4 (patch) | |
| tree | 0687cc4a0a4bdd20b5118541dd149a2a7a9ec8c0 /src/comp/syntax/parse/parser.rs | |
| parent | 75edd9ff69625292b1c4d5f05502d1fd28b39f55 (diff) | |
| download | rust-5ef53382aeac2de7e6dcc43c156312d2e68c15e4.tar.gz rust-5ef53382aeac2de7e6dcc43c156312d2e68c15e4.zip | |
Add support for parsing quasi-quotes, doesn't do anything useful yet.
Diffstat (limited to 'src/comp/syntax/parse/parser.rs')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 4a7b25f7c08..f2f1f7c14ed 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -628,6 +628,13 @@ fn parse_seq<T: copy>(bra: token::token, ket: token::token, ret spanned(lo, hi, result); } +fn have_dollar(p: parser) -> option::t<ast::mac_> { + alt p.token { + token::DOLLAR_NUM(num) {p.bump(); some(ast::mac_var(num))} + _ {none} + } +} + fn lit_from_token(p: parser, tok: token::token) -> ast::lit_ { alt tok { token::LIT_INT(i, it) { ast::lit_int(i, it) } @@ -755,6 +762,12 @@ fn parse_bottom_expr(p: parser) -> pexpr { let hi = p.span.hi; let ex: ast::expr_; + + alt have_dollar(p) { + some(x) {ret pexpr(mk_mac_expr(p, lo, p.span.hi, x));} + _ {} + } + if p.token == token::LPAREN { p.bump(); if p.token == token::RPAREN { @@ -843,6 +856,12 @@ fn parse_bottom_expr(p: parser) -> pexpr { } else if p.token == token::ELLIPSIS { p.bump(); ret pexpr(mk_mac_expr(p, lo, p.span.hi, ast::mac_ellipsis)); + } else if p.token == token::POUND_LPAREN { + p.bump(); + let e = parse_expr(p); + expect(p, token::RPAREN); + ret pexpr(mk_mac_expr(p, lo, p.span.hi, + ast::mac_qq(e.span, e))); } else if eat_word(p, "bind") { let e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS); fn parse_expr_opt(p: parser) -> option<@ast::expr> { |
