diff --git a/src/librustsyntax/parse/lexer.rs b/src/librustsyntax/parse/lexer.rs index dc5de0ad7bb..a7b109f2324 100644 --- a/src/librustsyntax/parse/lexer.rs +++ b/src/librustsyntax/parse/lexer.rs @@ -357,12 +357,7 @@ fn next_token_inner(rdr: reader) -> token::token { '[' { rdr.bump(); ret token::LBRACKET; } ']' { rdr.bump(); ret token::RBRACKET; } '@' { rdr.bump(); ret token::AT; } - '#' { - rdr.bump(); - if rdr.curr == '<' { rdr.bump(); ret token::POUND_LT; } - if rdr.curr == '{' { rdr.bump(); ret token::POUND_LBRACE; } - ret token::POUND; - } + '#' { rdr.bump(); ret token::POUND; } '~' { rdr.bump(); ret token::TILDE; } ':' { rdr.bump(); diff --git a/src/librustsyntax/parse/parser.rs b/src/librustsyntax/parse/parser.rs index 46ccb09b220..44d71fb3657 100644 --- a/src/librustsyntax/parse/parser.rs +++ b/src/librustsyntax/parse/parser.rs @@ -710,7 +710,8 @@ fn parse_bottom_expr(p: parser) -> pexpr { parse_expr, p); hi = p.span.hi; ex = ast::expr_vec(es, mutbl); - } else if p.token == token::POUND_LT { + } else if p.token == token::POUND && p.look_ahead(1u) == token::LT { + p.bump(); p.bump(); let ty = parse_ty(p, false); expect(p, token::GT); @@ -718,7 +719,8 @@ fn parse_bottom_expr(p: parser) -> pexpr { /* hack: early return to take advantage of specialized function */ ret pexpr(mk_mac_expr(p, lo, p.span.hi, ast::mac_embed_type(ty))); - } else if p.token == token::POUND_LBRACE { + } else if p.token == token::POUND && p.look_ahead(1u) == token::LBRACE { + p.bump(); p.bump(); let blk = ast::mac_embed_block( parse_block_tail(p, lo, ast::default_blk)); @@ -726,6 +728,10 @@ 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 { + let ex_ext = parse_syntax_ext(p); + hi = ex_ext.span.hi; + ex = ex_ext.node; } else if eat_word(p, "bind") { let e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS); let es = @@ -733,10 +739,6 @@ fn parse_bottom_expr(p: parser) -> pexpr { parse_expr_or_hole, p); hi = es.span.hi; ex = ast::expr_bind(e, es.node); - } else if p.token == token::POUND { - let ex_ext = parse_syntax_ext(p); - hi = ex_ext.span.hi; - ex = ex_ext.node; } else if eat_word(p, "fail") { if can_begin_expr(p.token) { let e = parse_expr(p); diff --git a/src/librustsyntax/parse/token.rs b/src/librustsyntax/parse/token.rs index c594d3e1ead..0088b7c4729 100644 --- a/src/librustsyntax/parse/token.rs +++ b/src/librustsyntax/parse/token.rs @@ -53,8 +53,6 @@ enum token { LBRACE, RBRACE, POUND, - POUND_LBRACE, - POUND_LT, DOLLAR_LPAREN, DOLLAR_NUM(uint), @@ -124,8 +122,6 @@ fn to_str(in: interner, t: token) -> str { LBRACE { ret "{"; } RBRACE { ret "}"; } POUND { ret "#"; } - POUND_LBRACE { ret "#{"; } - POUND_LT { ret "#<"; } DOLLAR_LPAREN { ret "$("; } DOLLAR_NUM(u) {