diff options
| author | bors <bors@rust-lang.org> | 2014-10-29 10:22:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-29 10:22:01 +0000 |
| commit | 3bc545373df4c81ba223a8bece14cbc27eb85a4d (patch) | |
| tree | 6f2bc6000e1b8b10a1a74aedc57fa9d1f0fc565b /src/libsyntax/ext/tt/macro_parser.rs | |
| parent | 124508dea1caf213886e5e1a02d425cac8dd0b54 (diff) | |
| parent | 665ad9c175f746b78c7eae81432b543d2e16c3c9 (diff) | |
| download | rust-3bc545373df4c81ba223a8bece14cbc27eb85a4d.tar.gz rust-3bc545373df4c81ba223a8bece14cbc27eb85a4d.zip | |
auto merge of #18365 : bjz/rust/token, r=alexcrichton
[breaking-change]
(for syntax-extensions)
- Token variant identifiers have been converted to PascalCase for consistency with Rust coding standards
- Some free-functions in `syntax::token` have been converted to methods on `syntax::token::Token`:
- `can_begin_expr` -> `Token::can_begin_expr`
- `close_delimiter_for` -> `Token::get_close_delimiter`
- `is_lit` -> `Token::is_lit`
- `is_ident` -> `Token::is_ident`
- `is_path` -> `Token::is_path`
- `is_plain_ident` -> `Token::is_plain_ident`
- `is_lifetime` -> `Token::is_lifetime`
- `is_mutability` -> `Token::is_mutability`
- `to_binop` -> `Token::to_binop`
- `is_keyword` -> `Token::is_keyword`
- `is_any_keyword` -> `Token:is_any_keyword`
- `is_strict_keyword` -> `Token::is_strict_keyword`
- `is_reserved_keyword` -> `Token::is_reserved_keyword`
- `mtwt_token_eq` -> `Token::mtwt_eq`
- `token::Ident` now takes an enum instead of a boolean for clarity
- `token::{to_string, binop_to_string}` were moved to `pprust::{token_to_string, binop_to_string}`
Diffstat (limited to 'src/libsyntax/ext/tt/macro_parser.rs')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index cea8cab5265..073bebcb3f6 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -85,8 +85,9 @@ use parse::lexer::*; //resolve bug? use parse::ParseSess; use parse::attr::ParserAttr; use parse::parser::{LifetimeAndTypesWithoutColons, Parser}; -use parse::token::{Token, EOF, Nonterminal}; +use parse::token::{Token, Nonterminal}; use parse::token; +use print::pprust; use ptr::P; use std::rc::Rc; @@ -226,8 +227,8 @@ pub fn parse_or_else(sess: &ParseSess, /// unhygienic comparison) pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool { match (t1,t2) { - (&token::IDENT(id1,_),&token::IDENT(id2,_)) - | (&token::LIFETIME(id1),&token::LIFETIME(id2)) => + (&token::Ident(id1,_),&token::Ident(id2,_)) + | (&token::Lifetime(id1),&token::Lifetime(id2)) => id1.name == id2.name, _ => *t1 == *t2 } @@ -354,9 +355,9 @@ pub fn parse(sess: &ParseSess, // Built-in nonterminals never start with these tokens, // so we can eliminate them from consideration. match tok { - token::RPAREN | - token::RBRACE | - token::RBRACKET => {}, + token::RParen | + token::RBrace | + token::RBracket => {}, _ => bb_eis.push(ei) } } @@ -372,7 +373,7 @@ pub fn parse(sess: &ParseSess, } /* error messages here could be improved with links to orig. rules */ - if token_name_eq(&tok, &EOF) { + if token_name_eq(&tok, &token::Eof) { if eof_eis.len() == 1u { let mut v = Vec::new(); for dv in eof_eis.get_mut(0).matches.iter_mut() { @@ -402,7 +403,7 @@ pub fn parse(sess: &ParseSess, nts, next_eis.len()).to_string()); } else if bb_eis.len() == 0u && next_eis.len() == 0u { return Failure(sp, format!("no rules expected the token `{}`", - token::to_string(&tok)).to_string()); + pprust::token_to_string(&tok)).to_string()); } else if next_eis.len() > 0u { /* Now process the next token */ while next_eis.len() > 0u { @@ -447,9 +448,9 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal { "ty" => token::NtTy(p.parse_ty(false /* no need to disambiguate*/)), // this could be handled like a token, since it is one "ident" => match p.token { - token::IDENT(sn,b) => { p.bump(); token::NtIdent(box sn,b) } + token::Ident(sn,b) => { p.bump(); token::NtIdent(box sn,b) } _ => { - let token_str = token::to_string(&p.token); + let token_str = pprust::token_to_string(&p.token); p.fatal((format!("expected ident, found {}", token_str.as_slice())).as_slice()) } |
