@@ -326,7 +326,7 @@ pub mod special_idents {
326
326
pub static unary_minus_fn : Ident = Ident { name : 6 , ctxt : 0 } ; // apparently unused?
327
327
pub static clownshoes_extensions : Ident = Ident { name : 7 , ctxt : 0 } ;
328
328
329
- pub static self_ : Ident = Ident { name : 8 , ctxt : 0 } ; // 'self'
329
+ pub static self_ : Ident = Ident { name : super :: SELF_KEYWORD_NAME , ctxt : 0 } ; // 'self'
330
330
331
331
/* for matcher NTs */
332
332
// none of these appear to be used, but perhaps references to
@@ -352,7 +352,7 @@ pub mod special_idents {
352
352
pub static main : Ident = Ident { name : 24 , ctxt : 0 } ;
353
353
pub static opaque : Ident = Ident { name : 25 , ctxt : 0 } ;
354
354
pub static blk : Ident = Ident { name : 26 , ctxt : 0 } ;
355
- pub static statik : Ident = Ident { name : 27 , ctxt : 0 } ;
355
+ pub static statik : Ident = Ident { name : super :: STATIC_KEYWORD_NAME , ctxt : 0 } ;
356
356
pub static clownshoes_foreign_mod: Ident = Ident { name : 28 , ctxt : 0 } ;
357
357
pub static unnamed_field: Ident = Ident { name : 29 , ctxt : 0 } ;
358
358
pub static c_abi: Ident = Ident { name : 30 , ctxt : 0 } ; // apparently unused?
@@ -414,8 +414,9 @@ pub type ident_interner = StrInterner;
414
414
415
415
// return a fresh interner, preloaded with special identifiers.
416
416
fn mk_fresh_ident_interner ( ) -> @ident_interner {
417
- // the indices here must correspond to the numbers in
418
- // special_idents.
417
+ // The indices here must correspond to the numbers in
418
+ // special_idents, in Keyword to_ident(), and in static
419
+ // constants below.
419
420
let init_vec = ~[
420
421
"_" , // 0
421
422
"anon" , // 1
@@ -473,8 +474,8 @@ fn mk_fresh_ident_interner() -> @ident_interner {
473
474
"pub" , // 52
474
475
"ref" , // 53
475
476
"return" , // 54
476
- "static" , // 27 -- also a special ident
477
- "self" , // 8 -- also a special ident
477
+ "static" , // 27 -- also a special ident (prefill de-dupes)
478
+ "self" , // 8 -- also a special ident (prefill de-dupes)
478
479
"struct" , // 55
479
480
"super" , // 56
480
481
"true" , // 57
@@ -498,6 +499,32 @@ fn mk_fresh_ident_interner() -> @ident_interner {
498
499
@interner:: StrInterner :: prefill ( init_vec)
499
500
}
500
501
502
+ // NOTE remove stage0 pub'ed special cases after next snapshot.
503
+ #[ cfg( stage0) ]
504
+ pub static SELF_KEYWORD_NAME : uint = 8 ;
505
+ #[ cfg( not( stage0) ) ]
506
+ static SELF_KEYWORD_NAME : uint = 8 ;
507
+ #[ cfg( stage0) ]
508
+ pub static STATIC_KEYWORD_NAME : uint = 27 ;
509
+ #[ cfg( not( stage0) ) ]
510
+ static STATIC_KEYWORD_NAME : uint = 27 ;
511
+ #[ cfg( stage0) ]
512
+ pub static STRICT_KEYWORD_START : uint = 32 ;
513
+ #[ cfg( not( stage0) ) ]
514
+ static STRICT_KEYWORD_START : uint = 32 ;
515
+ #[ cfg( stage0) ]
516
+ pub static STRICT_KEYWORD_FINAL : uint = 64 ;
517
+ #[ cfg( not( stage0) ) ]
518
+ static STRICT_KEYWORD_FINAL : uint = 64 ;
519
+ #[ cfg( stage0) ]
520
+ pub static RESERVED_KEYWORD_START : uint = 65 ;
521
+ #[ cfg( not( stage0) ) ]
522
+ static RESERVED_KEYWORD_START : uint = 65 ;
523
+ #[ cfg( stage0) ]
524
+ pub static RESERVED_KEYWORD_FINAL : uint = 71 ;
525
+ #[ cfg( not( stage0) ) ]
526
+ static RESERVED_KEYWORD_FINAL : uint = 71 ;
527
+
501
528
// if an interner exists in TLS, return it. Otherwise, prepare a
502
529
// fresh one.
503
530
pub fn get_ident_interner ( ) -> @ident_interner {
@@ -675,8 +702,8 @@ pub mod keywords {
675
702
Pub => Ident { name : 52 , ctxt : 0 } ,
676
703
Ref => Ident { name : 53 , ctxt : 0 } ,
677
704
Return => Ident { name : 54 , ctxt : 0 } ,
678
- Static => Ident { name : 27 , ctxt : 0 } ,
679
- Self => Ident { name : 8 , ctxt : 0 } ,
705
+ Static => Ident { name : super :: STATIC_KEYWORD_NAME , ctxt : 0 } ,
706
+ Self => Ident { name : super :: SELF_KEYWORD_NAME , ctxt : 0 } ,
680
707
Struct => Ident { name : 55 , ctxt : 0 } ,
681
708
Super => Ident { name : 56 , ctxt : 0 } ,
682
709
True => Ident { name : 57 , ctxt : 0 } ,
@@ -709,7 +736,8 @@ pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
709
736
pub fn is_any_keyword ( tok : & Token ) -> bool {
710
737
match * tok {
711
738
token:: IDENT ( sid, false ) => match sid. name {
712
- 8 | 27 | 32 .. 70 => true ,
739
+ SELF_KEYWORD_NAME | STATIC_KEYWORD_NAME |
740
+ STRICT_KEYWORD_START .. RESERVED_KEYWORD_FINAL => true ,
713
741
_ => false ,
714
742
} ,
715
743
_ => false
@@ -719,7 +747,8 @@ pub fn is_any_keyword(tok: &Token) -> bool {
719
747
pub fn is_strict_keyword ( tok : & Token ) -> bool {
720
748
match * tok {
721
749
token:: IDENT ( sid, false ) => match sid. name {
722
- 8 | 27 | 32 .. 64 => true ,
750
+ SELF_KEYWORD_NAME | STATIC_KEYWORD_NAME |
751
+ STRICT_KEYWORD_START .. STRICT_KEYWORD_FINAL => true ,
723
752
_ => false ,
724
753
} ,
725
754
_ => false ,
@@ -729,7 +758,7 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
729
758
pub fn is_reserved_keyword ( tok : & Token ) -> bool {
730
759
match * tok {
731
760
token:: IDENT ( sid, false ) => match sid. name {
732
- 65 .. 71 => true ,
761
+ RESERVED_KEYWORD_START .. RESERVED_KEYWORD_FINAL => true ,
733
762
_ => false ,
734
763
} ,
735
764
_ => false ,
0 commit comments