libsyntax: Remove drop
as a keyword.
This commit is contained in:
parent
b7a6919899
commit
73c1839579
1 changed files with 202 additions and 35 deletions
|
@ -400,7 +400,9 @@ impl ident_interner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// return a fresh interner, preloaded with special identifiers.
|
// return a fresh interner, preloaded with special identifiers.
|
||||||
|
#[cfg(stage0)]
|
||||||
fn mk_fresh_ident_interner() -> @ident_interner {
|
fn mk_fresh_ident_interner() -> @ident_interner {
|
||||||
// the indices here must correspond to the numbers in
|
// the indices here must correspond to the numbers in
|
||||||
// special_idents.
|
// special_idents.
|
||||||
|
@ -486,6 +488,92 @@ fn mk_fresh_ident_interner() -> @ident_interner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return a fresh interner, preloaded with special identifiers.
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
fn mk_fresh_ident_interner() -> @ident_interner {
|
||||||
|
// the indices here must correspond to the numbers in
|
||||||
|
// special_idents.
|
||||||
|
let init_vec = ~[
|
||||||
|
"_", // 0
|
||||||
|
"anon", // 1
|
||||||
|
"", // 2
|
||||||
|
"unary", // 3
|
||||||
|
"!", // 4
|
||||||
|
"[]", // 5
|
||||||
|
"unary-", // 6
|
||||||
|
"__extensions__", // 7
|
||||||
|
"self", // 8
|
||||||
|
"item", // 9
|
||||||
|
"block", // 10
|
||||||
|
"stmt", // 11
|
||||||
|
"pat", // 12
|
||||||
|
"expr", // 13
|
||||||
|
"ty", // 14
|
||||||
|
"ident", // 15
|
||||||
|
"path", // 16
|
||||||
|
"tt", // 17
|
||||||
|
"matchers", // 18
|
||||||
|
"str", // 19
|
||||||
|
"TyVisitor", // 20
|
||||||
|
"arg", // 21
|
||||||
|
"descrim", // 22
|
||||||
|
"__rust_abi", // 23
|
||||||
|
"__rust_stack_shim", // 24
|
||||||
|
"TyDesc", // 25
|
||||||
|
"main", // 26
|
||||||
|
"<opaque>", // 27
|
||||||
|
"blk", // 28
|
||||||
|
"static", // 29
|
||||||
|
"intrinsic", // 30
|
||||||
|
"__foreign_mod__", // 31
|
||||||
|
"__field__", // 32
|
||||||
|
"C", // 33
|
||||||
|
"Self", // 34
|
||||||
|
|
||||||
|
"as", // 35
|
||||||
|
"break", // 36
|
||||||
|
"const", // 37
|
||||||
|
"copy", // 38
|
||||||
|
"do", // 39
|
||||||
|
"else", // 40
|
||||||
|
"enum", // 41
|
||||||
|
"extern", // 42
|
||||||
|
"false", // 43
|
||||||
|
"fn", // 44
|
||||||
|
"for", // 45
|
||||||
|
"if", // 46
|
||||||
|
"impl", // 47
|
||||||
|
"let", // 48
|
||||||
|
"__log", // 49
|
||||||
|
"loop", // 50
|
||||||
|
"match", // 51
|
||||||
|
"mod", // 52
|
||||||
|
"mut", // 53
|
||||||
|
"once", // 54
|
||||||
|
"priv", // 55
|
||||||
|
"pub", // 56
|
||||||
|
"pure", // 57
|
||||||
|
"ref", // 58
|
||||||
|
"return", // 59
|
||||||
|
"static", // 29 -- also a special ident
|
||||||
|
"self", // 8 -- also a special ident
|
||||||
|
"struct", // 60
|
||||||
|
"super", // 61
|
||||||
|
"true", // 62
|
||||||
|
"trait", // 63
|
||||||
|
"type", // 64
|
||||||
|
"unsafe", // 65
|
||||||
|
"use", // 66
|
||||||
|
"while", // 67
|
||||||
|
|
||||||
|
"be", // 68
|
||||||
|
];
|
||||||
|
|
||||||
|
@ident_interner {
|
||||||
|
interner: interner::StrInterner::prefill(init_vec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if an interner exists in TLS, return it. Otherwise, prepare a
|
// if an interner exists in TLS, return it. Otherwise, prepare a
|
||||||
// fresh one.
|
// fresh one.
|
||||||
pub fn get_ident_interner() -> @ident_interner {
|
pub fn get_ident_interner() -> @ident_interner {
|
||||||
|
@ -612,6 +700,7 @@ pub mod keywords {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Keyword {
|
impl Keyword {
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn to_ident(&self) -> ident {
|
pub fn to_ident(&self) -> ident {
|
||||||
match *self {
|
match *self {
|
||||||
As => ident { name: 35, ctxt: 0 },
|
As => ident { name: 35, ctxt: 0 },
|
||||||
|
@ -652,6 +741,47 @@ pub mod keywords {
|
||||||
Be => ident { name: 69, ctxt: 0 },
|
Be => ident { name: 69, ctxt: 0 },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
pub fn to_ident(&self) -> ident {
|
||||||
|
match *self {
|
||||||
|
As => ident { name: 35, ctxt: 0 },
|
||||||
|
Break => ident { name: 36, ctxt: 0 },
|
||||||
|
Const => ident { name: 37, ctxt: 0 },
|
||||||
|
Copy => ident { name: 38, ctxt: 0 },
|
||||||
|
Do => ident { name: 39, ctxt: 0 },
|
||||||
|
Else => ident { name: 40, ctxt: 0 },
|
||||||
|
Enum => ident { name: 41, ctxt: 0 },
|
||||||
|
Extern => ident { name: 42, ctxt: 0 },
|
||||||
|
False => ident { name: 43, ctxt: 0 },
|
||||||
|
Fn => ident { name: 44, ctxt: 0 },
|
||||||
|
For => ident { name: 45, ctxt: 0 },
|
||||||
|
If => ident { name: 46, ctxt: 0 },
|
||||||
|
Impl => ident { name: 47, ctxt: 0 },
|
||||||
|
Let => ident { name: 48, ctxt: 0 },
|
||||||
|
__Log => ident { name: 49, ctxt: 0 },
|
||||||
|
Loop => ident { name: 50, ctxt: 0 },
|
||||||
|
Match => ident { name: 51, ctxt: 0 },
|
||||||
|
Mod => ident { name: 52, ctxt: 0 },
|
||||||
|
Mut => ident { name: 53, ctxt: 0 },
|
||||||
|
Once => ident { name: 54, ctxt: 0 },
|
||||||
|
Priv => ident { name: 55, ctxt: 0 },
|
||||||
|
Pub => ident { name: 56, ctxt: 0 },
|
||||||
|
Pure => ident { name: 57, ctxt: 0 },
|
||||||
|
Ref => ident { name: 58, ctxt: 0 },
|
||||||
|
Return => ident { name: 59, ctxt: 0 },
|
||||||
|
Static => ident { name: 29, ctxt: 0 },
|
||||||
|
Self => ident { name: 8, ctxt: 0 },
|
||||||
|
Struct => ident { name: 60, ctxt: 0 },
|
||||||
|
Super => ident { name: 61, ctxt: 0 },
|
||||||
|
True => ident { name: 62, ctxt: 0 },
|
||||||
|
Trait => ident { name: 63, ctxt: 0 },
|
||||||
|
Type => ident { name: 64, ctxt: 0 },
|
||||||
|
Unsafe => ident { name: 65, ctxt: 0 },
|
||||||
|
Use => ident { name: 66, ctxt: 0 },
|
||||||
|
While => ident { name: 67, ctxt: 0 },
|
||||||
|
Be => ident { name: 68, ctxt: 0 },
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,6 +792,7 @@ pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn is_any_keyword(tok: &Token) -> bool {
|
pub fn is_any_keyword(tok: &Token) -> bool {
|
||||||
match *tok {
|
match *tok {
|
||||||
token::IDENT(sid, false) => match sid.name {
|
token::IDENT(sid, false) => match sid.name {
|
||||||
|
@ -672,6 +803,18 @@ pub fn is_any_keyword(tok: &Token) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
pub fn is_any_keyword(tok: &Token) -> bool {
|
||||||
|
match *tok {
|
||||||
|
token::IDENT(sid, false) => match sid.name {
|
||||||
|
8 | 29 | 35 .. 68 => true,
|
||||||
|
_ => false,
|
||||||
|
},
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn is_strict_keyword(tok: &Token) -> bool {
|
pub fn is_strict_keyword(tok: &Token) -> bool {
|
||||||
match *tok {
|
match *tok {
|
||||||
token::IDENT(sid, false) => match sid.name {
|
token::IDENT(sid, false) => match sid.name {
|
||||||
|
@ -682,6 +825,18 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
pub fn is_strict_keyword(tok: &Token) -> bool {
|
||||||
|
match *tok {
|
||||||
|
token::IDENT(sid, false) => match sid.name {
|
||||||
|
8 | 29 | 35 .. 67 => true,
|
||||||
|
_ => false,
|
||||||
|
},
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn is_reserved_keyword(tok: &Token) -> bool {
|
pub fn is_reserved_keyword(tok: &Token) -> bool {
|
||||||
match *tok {
|
match *tok {
|
||||||
token::IDENT(sid, false) => match sid.name {
|
token::IDENT(sid, false) => match sid.name {
|
||||||
|
@ -692,6 +847,18 @@ pub fn is_reserved_keyword(tok: &Token) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
pub fn is_reserved_keyword(tok: &Token) -> bool {
|
||||||
|
match *tok {
|
||||||
|
token::IDENT(sid, false) => match sid.name {
|
||||||
|
68 => true,
|
||||||
|
_ => false,
|
||||||
|
},
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue