get rid of keyword idents, replace with names
should prevent future bugs
This commit is contained in:
parent
06b64345d6
commit
c1b8b3c35c
2 changed files with 8 additions and 8 deletions
|
@ -542,7 +542,7 @@ impl<'a> Parser<'a> {
|
|||
// true. Otherwise, return false.
|
||||
pub fn eat_keyword(&mut self, kw: keywords::Keyword) -> bool {
|
||||
match self.token {
|
||||
token::IDENT(sid, false) if kw.to_ident().name == sid.name => {
|
||||
token::IDENT(sid, false) if kw.to_name() == sid.name => {
|
||||
self.bump();
|
||||
true
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ impl<'a> Parser<'a> {
|
|||
// otherwise, eat it.
|
||||
pub fn expect_keyword(&mut self, kw: keywords::Keyword) {
|
||||
if !self.eat_keyword(kw) {
|
||||
let id_interned_str = token::get_ident(kw.to_ident());
|
||||
let id_interned_str = token::get_name(kw.to_name());
|
||||
let token_str = self.this_token_to_string();
|
||||
self.fatal(format!("expected `{}`, found `{}`",
|
||||
id_interned_str, token_str).as_slice())
|
||||
|
|
|
@ -413,7 +413,7 @@ macro_rules! declare_special_idents_and_keywords {(
|
|||
* the language and may not appear as identifiers.
|
||||
*/
|
||||
pub mod keywords {
|
||||
use ast::Ident;
|
||||
use ast::Name;
|
||||
|
||||
pub enum Keyword {
|
||||
$( $sk_variant, )*
|
||||
|
@ -421,10 +421,10 @@ macro_rules! declare_special_idents_and_keywords {(
|
|||
}
|
||||
|
||||
impl Keyword {
|
||||
pub fn to_ident(&self) -> Ident {
|
||||
pub fn to_name(&self) -> Name {
|
||||
match *self {
|
||||
$( $sk_variant => Ident { name: $sk_name, ctxt: 0 }, )*
|
||||
$( $rk_variant => Ident { name: $rk_name, ctxt: 0 }, )*
|
||||
$( $sk_variant => $sk_name, )*
|
||||
$( $rk_variant => $rk_name, )*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ macro_rules! declare_special_idents_and_keywords {(
|
|||
|
||||
fn mk_fresh_ident_interner() -> IdentInterner {
|
||||
// The indices here must correspond to the numbers in
|
||||
// special_idents, in Keyword to_ident(), and in static
|
||||
// special_idents, in Keyword to_name(), and in static
|
||||
// constants below.
|
||||
let mut init_vec = Vec::new();
|
||||
$(init_vec.push($si_str);)*
|
||||
|
@ -710,7 +710,7 @@ pub fn fresh_mark() -> Mrk {
|
|||
|
||||
pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
|
||||
match *tok {
|
||||
token::IDENT(sid, false) => { kw.to_ident().name == sid.name }
|
||||
token::IDENT(sid, false) => { kw.to_name() == sid.name }
|
||||
_ => { false }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue