Skip to content

Commit

Permalink
libsyntax: Remove drop as a keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana authored and Aatch committed Jun 20, 2013
1 parent b7a6919 commit 73c1839
Showing 1 changed file with 202 additions and 35 deletions.
237 changes: 202 additions & 35 deletions src/libsyntax/parse/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ impl ident_interner {
}
}


// return a fresh interner, preloaded with special identifiers.
#[cfg(stage0)]
fn mk_fresh_ident_interner() -> @ident_interner {
// the indices here must correspond to the numbers in
// special_idents.
Expand Down Expand Up @@ -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
// fresh one.
pub fn get_ident_interner() -> @ident_interner {
Expand Down Expand Up @@ -612,44 +700,86 @@ pub mod keywords {
}

impl Keyword {
#[cfg(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: 41, ctxt: 0 },
Enum => ident { name: 42, ctxt: 0 },
Extern => ident { name: 43, ctxt: 0 },
False => ident { name: 44, ctxt: 0 },
Fn => ident { name: 45, ctxt: 0 },
For => ident { name: 46, ctxt: 0 },
If => ident { name: 47, ctxt: 0 },
Impl => ident { name: 48, ctxt: 0 },
Let => ident { name: 49, ctxt: 0 },
__Log => ident { name: 50, ctxt: 0 },
Loop => ident { name: 51, ctxt: 0 },
Match => ident { name: 52, ctxt: 0 },
Mod => ident { name: 53, ctxt: 0 },
Mut => ident { name: 54, ctxt: 0 },
Once => ident { name: 55, ctxt: 0 },
Priv => ident { name: 56, ctxt: 0 },
Pub => ident { name: 57, ctxt: 0 },
Pure => ident { name: 58, ctxt: 0 },
Ref => ident { name: 59, ctxt: 0 },
Return => ident { name: 60, ctxt: 0 },
Static => ident { name: 29, ctxt: 0 },
Self => ident { name: 8, ctxt: 0 },
Struct => ident { name: 61, ctxt: 0 },
Super => ident { name: 62, ctxt: 0 },
True => ident { name: 63, ctxt: 0 },
Trait => ident { name: 64, ctxt: 0 },
Type => ident { name: 65, ctxt: 0 },
Unsafe => ident { name: 66, ctxt: 0 },
Use => ident { name: 67, ctxt: 0 },
While => ident { name: 68, ctxt: 0 },
Be => ident { name: 69, 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: 41, ctxt: 0 },
Enum => ident { name: 42, ctxt: 0 },
Extern => ident { name: 43, ctxt: 0 },
False => ident { name: 44, ctxt: 0 },
Fn => ident { name: 45, ctxt: 0 },
For => ident { name: 46, ctxt: 0 },
If => ident { name: 47, ctxt: 0 },
Impl => ident { name: 48, ctxt: 0 },
Let => ident { name: 49, ctxt: 0 },
__Log => ident { name: 50, ctxt: 0 },
Loop => ident { name: 51, ctxt: 0 },
Match => ident { name: 52, ctxt: 0 },
Mod => ident { name: 53, ctxt: 0 },
Mut => ident { name: 54, ctxt: 0 },
Once => ident { name: 55, ctxt: 0 },
Priv => ident { name: 56, ctxt: 0 },
Pub => ident { name: 57, ctxt: 0 },
Pure => ident { name: 58, ctxt: 0 },
Ref => ident { name: 59, ctxt: 0 },
Return => ident { name: 60, ctxt: 0 },
Static => ident { name: 29, ctxt: 0 },
Self => ident { name: 8, ctxt: 0 },
Struct => ident { name: 61, ctxt: 0 },
Super => ident { name: 62, ctxt: 0 },
True => ident { name: 63, ctxt: 0 },
Trait => ident { name: 64, ctxt: 0 },
Type => ident { name: 65, ctxt: 0 },
Unsafe => ident { name: 66, ctxt: 0 },
Use => ident { name: 67, ctxt: 0 },
While => ident { name: 68, 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 },
}
}
}
Expand All @@ -662,6 +792,7 @@ pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
}
}

#[cfg(stage0)]
pub fn is_any_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
Expand All @@ -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 {
match *tok {
token::IDENT(sid, false) => match sid.name {
Expand All @@ -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 {
match *tok {
token::IDENT(sid, false) => match sid.name {
Expand All @@ -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)]
mod test {
use super::*;
Expand Down

0 comments on commit 73c1839

Please sign in to comment.