Convert some token functions into methods
This commit is contained in:
parent
d8b1fa0ae0
commit
fcb78d65f2
9 changed files with 305 additions and 311 deletions
|
|
@ -116,8 +116,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool,
|
|||
return (invocation, None);
|
||||
}
|
||||
if p.token == token::Eof { break } // accept trailing commas
|
||||
if named || (token::is_ident(&p.token) &&
|
||||
p.look_ahead(1, |t| *t == token::Eq)) {
|
||||
if named || (p.token.is_ident() && p.look_ahead(1, |t| *t == token::Eq)) {
|
||||
named = true;
|
||||
let ident = match p.token {
|
||||
token::Ident(i, _) => {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use ast;
|
|||
use codemap::Span;
|
||||
use ext::base::ExtCtxt;
|
||||
use ext::base;
|
||||
use parse::token::{keywords, is_keyword};
|
||||
use parse::token::keywords;
|
||||
|
||||
|
||||
pub fn expand_trace_macros(cx: &mut ExtCtxt,
|
||||
|
|
@ -20,10 +20,10 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt,
|
|||
tt: &[ast::TokenTree])
|
||||
-> Box<base::MacResult+'static> {
|
||||
match tt {
|
||||
[ast::TtToken(_, ref tok)] if is_keyword(keywords::True, tok) => {
|
||||
[ast::TtToken(_, ref tok)] if tok.is_keyword(keywords::True) => {
|
||||
cx.set_trace_macros(true);
|
||||
}
|
||||
[ast::TtToken(_, ref tok)] if is_keyword(keywords::False, tok) => {
|
||||
[ast::TtToken(_, ref tok)] if tok.is_keyword(keywords::False) => {
|
||||
cx.set_trace_macros(false);
|
||||
}
|
||||
_ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue