libsyntax: De-@mut
token
in the parser
This commit is contained in:
parent
425a140485
commit
758d854436
10 changed files with 251 additions and 251 deletions
|
@ -66,9 +66,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
|
|||
asm_str_style = Some(style);
|
||||
}
|
||||
Outputs => {
|
||||
while *p.token != token::EOF &&
|
||||
*p.token != token::COLON &&
|
||||
*p.token != token::MOD_SEP {
|
||||
while p.token != token::EOF &&
|
||||
p.token != token::COLON &&
|
||||
p.token != token::MOD_SEP {
|
||||
|
||||
if outputs.len() != 0 {
|
||||
p.eat(&token::COMMA);
|
||||
|
@ -91,9 +91,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
|
|||
}
|
||||
}
|
||||
Inputs => {
|
||||
while *p.token != token::EOF &&
|
||||
*p.token != token::COLON &&
|
||||
*p.token != token::MOD_SEP {
|
||||
while p.token != token::EOF &&
|
||||
p.token != token::COLON &&
|
||||
p.token != token::MOD_SEP {
|
||||
|
||||
if inputs.len() != 0 {
|
||||
p.eat(&token::COMMA);
|
||||
|
@ -116,9 +116,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
|
|||
}
|
||||
Clobbers => {
|
||||
let mut clobs = ~[];
|
||||
while *p.token != token::EOF &&
|
||||
*p.token != token::COLON &&
|
||||
*p.token != token::MOD_SEP {
|
||||
while p.token != token::EOF &&
|
||||
p.token != token::COLON &&
|
||||
p.token != token::MOD_SEP {
|
||||
|
||||
if clobs.len() != 0 {
|
||||
p.eat(&token::COMMA);
|
||||
|
@ -142,16 +142,16 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
|
|||
dialect = ast::asm_intel;
|
||||
}
|
||||
|
||||
if *p.token == token::COMMA {
|
||||
if p.token == token::COMMA {
|
||||
p.eat(&token::COMMA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while *p.token == token::COLON ||
|
||||
*p.token == token::MOD_SEP ||
|
||||
*p.token == token::EOF {
|
||||
state = if *p.token == token::COLON {
|
||||
while p.token == token::COLON ||
|
||||
p.token == token::MOD_SEP ||
|
||||
p.token == token::EOF {
|
||||
state = if p.token == token::COLON {
|
||||
p.bump();
|
||||
match next_state(state) {
|
||||
Some(x) => x,
|
||||
|
@ -160,7 +160,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
|
|||
break
|
||||
}
|
||||
}
|
||||
} else if *p.token == token::MOD_SEP {
|
||||
} else if p.token == token::MOD_SEP {
|
||||
p.bump();
|
||||
let s = match next_state(state) {
|
||||
Some(x) => x,
|
||||
|
@ -176,7 +176,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
|
|||
break
|
||||
}
|
||||
}
|
||||
} else if *p.token == token::EOF {
|
||||
} else if p.token == token::EOF {
|
||||
continue_ = false;
|
||||
break;
|
||||
} else {
|
||||
|
|
|
@ -446,7 +446,7 @@ pub fn get_exprs_from_tts(cx: &ExtCtxt,
|
|||
cx.cfg(),
|
||||
tts.to_owned());
|
||||
let mut es = ~[];
|
||||
while *p.token != token::EOF {
|
||||
while p.token != token::EOF {
|
||||
if es.len() != 0 && !p.eat(&token::COMMA) {
|
||||
cx.span_fatal(sp, "expected token: `,`");
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ pub fn expand_cfg(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::
|
|||
|
||||
let mut cfgs = ~[];
|
||||
// parse `cfg!(meta_item, meta_item(x,y), meta_item="foo", ...)`
|
||||
while *p.token != token::EOF {
|
||||
while p.token != token::EOF {
|
||||
cfgs.push(p.parse_meta_item());
|
||||
if p.eat(&token::EOF) { break } // trailing comma is optional,.
|
||||
p.expect(&token::COMMA);
|
||||
|
|
|
@ -65,22 +65,22 @@ impl<'a> Context<'a> {
|
|||
return (extra, None);
|
||||
}
|
||||
|
||||
if *p.token == token::EOF {
|
||||
if p.token == token::EOF {
|
||||
self.ecx.span_err(sp, "requires at least a format string argument");
|
||||
return (extra, None);
|
||||
}
|
||||
let fmtstr = p.parse_expr();
|
||||
let mut named = false;
|
||||
while *p.token != token::EOF {
|
||||
while p.token != token::EOF {
|
||||
if !p.eat(&token::COMMA) {
|
||||
self.ecx.span_err(sp, "expected token: `,`");
|
||||
return (extra, None);
|
||||
}
|
||||
if *p.token == token::EOF { break } // accept trailing commas
|
||||
if named || (token::is_ident(p.token) &&
|
||||
if p.token == token::EOF { break } // accept trailing commas
|
||||
if named || (token::is_ident(&p.token) &&
|
||||
p.look_ahead(1, |t| *t == token::EQ)) {
|
||||
named = true;
|
||||
let ident = match *p.token {
|
||||
let ident = match p.token {
|
||||
token::IDENT(i, _) => {
|
||||
p.bump();
|
||||
i
|
||||
|
|
|
@ -438,10 +438,12 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> nonterminal {
|
|||
"expr" => token::nt_expr(p.parse_expr()),
|
||||
"ty" => token::nt_ty(p.parse_ty(false /* no need to disambiguate*/)),
|
||||
// this could be handled like a token, since it is one
|
||||
"ident" => match *p.token {
|
||||
"ident" => match p.token {
|
||||
token::IDENT(sn,b) => { p.bump(); token::nt_ident(~sn,b) }
|
||||
_ => p.fatal(~"expected ident, found "
|
||||
+ token::to_str(get_ident_interner(), p.token))
|
||||
_ => {
|
||||
let token_str = token::to_str(get_ident_interner(), &p.token);
|
||||
p.fatal(~"expected ident, found " + token_str)
|
||||
}
|
||||
},
|
||||
"path" => {
|
||||
token::nt_path(~p.parse_path(LifetimeAndTypesWithoutColons).path)
|
||||
|
|
|
@ -40,10 +40,10 @@ impl ParserAnyMacro {
|
|||
/// allowed to be there.
|
||||
fn ensure_complete_parse(&self, allow_semi: bool) {
|
||||
let mut parser = self.parser.borrow_mut();
|
||||
if allow_semi && *parser.get().token == SEMI {
|
||||
if allow_semi && parser.get().token == SEMI {
|
||||
parser.get().bump()
|
||||
}
|
||||
if *parser.get().token != EOF {
|
||||
if parser.get().token != EOF {
|
||||
let token_str = parser.get().this_token_to_str();
|
||||
let msg = format!("macro expansion ignores token `{}` and any \
|
||||
following",
|
||||
|
|
|
@ -33,7 +33,7 @@ impl parser_attr for Parser {
|
|||
loop {
|
||||
debug!("parse_outer_attributes: self.token={:?}",
|
||||
self.token);
|
||||
match *self.token {
|
||||
match self.token {
|
||||
token::INTERPOLATED(token::nt_attr(..)) => {
|
||||
attrs.push(self.parse_attribute(false));
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ impl parser_attr for Parser {
|
|||
fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute {
|
||||
debug!("parse_attributes: permit_inner={:?} self.token={:?}",
|
||||
permit_inner, self.token);
|
||||
let (span, value) = match *self.token {
|
||||
let (span, value) = match self.token {
|
||||
INTERPOLATED(token::nt_attr(attr)) => {
|
||||
assert!(attr.node.style == ast::AttrOuter);
|
||||
self.bump();
|
||||
|
@ -89,7 +89,7 @@ impl parser_attr for Parser {
|
|||
token_str));
|
||||
}
|
||||
};
|
||||
let style = if permit_inner && *self.token == token::SEMI {
|
||||
let style = if permit_inner && self.token == token::SEMI {
|
||||
self.bump();
|
||||
ast::AttrInner
|
||||
} else {
|
||||
|
@ -120,7 +120,7 @@ impl parser_attr for Parser {
|
|||
let mut inner_attrs: ~[ast::Attribute] = ~[];
|
||||
let mut next_outer_attrs: ~[ast::Attribute] = ~[];
|
||||
loop {
|
||||
let attr = match *self.token {
|
||||
let attr = match self.token {
|
||||
token::INTERPOLATED(token::nt_attr(..)) => {
|
||||
self.parse_attribute(true)
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ impl parser_attr for Parser {
|
|||
let lo = self.span.lo;
|
||||
let ident = self.parse_ident();
|
||||
let name = self.id_to_str(ident);
|
||||
match *self.token {
|
||||
match self.token {
|
||||
token::EQ => {
|
||||
self.bump();
|
||||
let lit = self.parse_lit();
|
||||
|
@ -196,7 +196,7 @@ impl parser_attr for Parser {
|
|||
}
|
||||
|
||||
fn parse_optional_meta(&mut self) -> ~[@ast::MetaItem] {
|
||||
match *self.token {
|
||||
match self.token {
|
||||
token::LPAREN => self.parse_meta_seq(),
|
||||
_ => ~[]
|
||||
}
|
||||
|
|
|
@ -631,7 +631,7 @@ mod test {
|
|||
}
|
||||
|
||||
fn parser_done(p: Parser){
|
||||
assert_eq!((*p.token).clone(), token::EOF);
|
||||
assert_eq!(p.token.clone(), token::EOF);
|
||||
}
|
||||
|
||||
#[test] fn parse_ident_pat () {
|
||||
|
|
|
@ -20,7 +20,6 @@ removed.
|
|||
use ast::{Expr, ExprLit, lit_nil};
|
||||
use codemap::{Span, respan};
|
||||
use parse::parser::Parser;
|
||||
use parse::token::Token;
|
||||
use parse::token;
|
||||
|
||||
use std::str;
|
||||
|
@ -66,7 +65,6 @@ pub trait ParserObsoleteMethods {
|
|||
kind: ObsoleteSyntax,
|
||||
kind_str: &str,
|
||||
desc: &str);
|
||||
fn token_is_obsolete_ident(&mut self, ident: &str, token: &Token) -> bool;
|
||||
fn is_obsolete_ident(&mut self, ident: &str) -> bool;
|
||||
fn eat_obsolete_ident(&mut self, ident: &str) -> bool;
|
||||
}
|
||||
|
@ -176,9 +174,8 @@ impl ParserObsoleteMethods for Parser {
|
|||
}
|
||||
}
|
||||
|
||||
fn token_is_obsolete_ident(&mut self, ident: &str, token: &Token)
|
||||
-> bool {
|
||||
match *token {
|
||||
fn is_obsolete_ident(&mut self, ident: &str) -> bool {
|
||||
match self.token {
|
||||
token::IDENT(sid, _) => {
|
||||
str::eq_slice(self.id_to_str(sid), ident)
|
||||
}
|
||||
|
@ -186,10 +183,6 @@ impl ParserObsoleteMethods for Parser {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_obsolete_ident(&mut self, ident: &str) -> bool {
|
||||
self.token_is_obsolete_ident(ident, self.token)
|
||||
}
|
||||
|
||||
fn eat_obsolete_ident(&mut self, ident: &str) -> bool {
|
||||
if self.is_obsolete_ident(ident) {
|
||||
self.bump();
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue