@@ -400,7 +400,9 @@ impl ident_interner {
400400 }
401401}
402402
403+
403404// return a fresh interner, preloaded with special identifiers.
405+ #[ cfg( stage0) ]
404406fn mk_fresh_ident_interner ( ) -> @ident_interner {
405407 // the indices here must correspond to the numbers in
406408 // special_idents.
@@ -486,6 +488,92 @@ fn mk_fresh_ident_interner() -> @ident_interner {
486488 }
487489}
488490
491+ // return a fresh interner, preloaded with special identifiers.
492+ #[ cfg( not( stage0) ) ]
493+ fn mk_fresh_ident_interner ( ) -> @ident_interner {
494+ // the indices here must correspond to the numbers in
495+ // special_idents.
496+ let init_vec = ~[
497+ "_" , // 0
498+ "anon" , // 1
499+ "" , // 2
500+ "unary" , // 3
501+ "!" , // 4
502+ "[]" , // 5
503+ "unary-" , // 6
504+ "__extensions__" , // 7
505+ "self" , // 8
506+ "item" , // 9
507+ "block" , // 10
508+ "stmt" , // 11
509+ "pat" , // 12
510+ "expr" , // 13
511+ "ty" , // 14
512+ "ident" , // 15
513+ "path" , // 16
514+ "tt" , // 17
515+ "matchers" , // 18
516+ "str" , // 19
517+ "TyVisitor" , // 20
518+ "arg" , // 21
519+ "descrim" , // 22
520+ "__rust_abi" , // 23
521+ "__rust_stack_shim" , // 24
522+ "TyDesc" , // 25
523+ "main" , // 26
524+ "<opaque>" , // 27
525+ "blk" , // 28
526+ "static" , // 29
527+ "intrinsic" , // 30
528+ "__foreign_mod__" , // 31
529+ "__field__" , // 32
530+ "C" , // 33
531+ "Self" , // 34
532+
533+ "as" , // 35
534+ "break" , // 36
535+ "const" , // 37
536+ "copy" , // 38
537+ "do" , // 39
538+ "else" , // 40
539+ "enum" , // 41
540+ "extern" , // 42
541+ "false" , // 43
542+ "fn" , // 44
543+ "for" , // 45
544+ "if" , // 46
545+ "impl" , // 47
546+ "let" , // 48
547+ "__log" , // 49
548+ "loop" , // 50
549+ "match" , // 51
550+ "mod" , // 52
551+ "mut" , // 53
552+ "once" , // 54
553+ "priv" , // 55
554+ "pub" , // 56
555+ "pure" , // 57
556+ "ref" , // 58
557+ "return" , // 59
558+ "static" , // 29 -- also a special ident
559+ "self" , // 8 -- also a special ident
560+ "struct" , // 60
561+ "super" , // 61
562+ "true" , // 62
563+ "trait" , // 63
564+ "type" , // 64
565+ "unsafe" , // 65
566+ "use" , // 66
567+ "while" , // 67
568+
569+ "be" , // 68
570+ ] ;
571+
572+ @ident_interner {
573+ interner : interner:: StrInterner :: prefill ( init_vec)
574+ }
575+ }
576+
489577// if an interner exists in TLS, return it. Otherwise, prepare a
490578// fresh one.
491579pub fn get_ident_interner ( ) -> @ident_interner {
@@ -612,44 +700,86 @@ pub mod keywords {
612700 }
613701
614702 impl Keyword {
703+ #[ cfg( stage0) ]
615704 pub fn to_ident ( & self ) -> ident {
616705 match * self {
617706 As => ident { name : 35 , ctxt : 0 } ,
618- Break => ident { name : 36 , ctxt : 0 } ,
619- Const => ident { name : 37 , ctxt : 0 } ,
620- Copy => ident { name : 38 , ctxt : 0 } ,
621- Do => ident { name : 39 , ctxt : 0 } ,
622- Else => ident { name : 41 , ctxt : 0 } ,
623- Enum => ident { name : 42 , ctxt : 0 } ,
624- Extern => ident { name : 43 , ctxt : 0 } ,
625- False => ident { name : 44 , ctxt : 0 } ,
626- Fn => ident { name : 45 , ctxt : 0 } ,
627- For => ident { name : 46 , ctxt : 0 } ,
628- If => ident { name : 47 , ctxt : 0 } ,
629- Impl => ident { name : 48 , ctxt : 0 } ,
630- Let => ident { name : 49 , ctxt : 0 } ,
631- __Log => ident { name : 50 , ctxt : 0 } ,
632- Loop => ident { name : 51 , ctxt : 0 } ,
633- Match => ident { name : 52 , ctxt : 0 } ,
634- Mod => ident { name : 53 , ctxt : 0 } ,
635- Mut => ident { name : 54 , ctxt : 0 } ,
636- Once => ident { name : 55 , ctxt : 0 } ,
637- Priv => ident { name : 56 , ctxt : 0 } ,
638- Pub => ident { name : 57 , ctxt : 0 } ,
639- Pure => ident { name : 58 , ctxt : 0 } ,
640- Ref => ident { name : 59 , ctxt : 0 } ,
641- Return => ident { name : 60 , ctxt : 0 } ,
642- Static => ident { name : 29 , ctxt : 0 } ,
643- Self => ident { name : 8 , ctxt : 0 } ,
644- Struct => ident { name : 61 , ctxt : 0 } ,
645- Super => ident { name : 62 , ctxt : 0 } ,
646- True => ident { name : 63 , ctxt : 0 } ,
647- Trait => ident { name : 64 , ctxt : 0 } ,
648- Type => ident { name : 65 , ctxt : 0 } ,
649- Unsafe => ident { name : 66 , ctxt : 0 } ,
650- Use => ident { name : 67 , ctxt : 0 } ,
651- While => ident { name : 68 , ctxt : 0 } ,
652- Be => ident { name : 69 , ctxt : 0 } ,
707+ Break => ident { name : 36 , ctxt : 0 } ,
708+ Const => ident { name : 37 , ctxt : 0 } ,
709+ Copy => ident { name : 38 , ctxt : 0 } ,
710+ Do => ident { name : 39 , ctxt : 0 } ,
711+ Else => ident { name : 41 , ctxt : 0 } ,
712+ Enum => ident { name : 42 , ctxt : 0 } ,
713+ Extern => ident { name : 43 , ctxt : 0 } ,
714+ False => ident { name : 44 , ctxt : 0 } ,
715+ Fn => ident { name : 45 , ctxt : 0 } ,
716+ For => ident { name : 46 , ctxt : 0 } ,
717+ If => ident { name : 47 , ctxt : 0 } ,
718+ Impl => ident { name : 48 , ctxt : 0 } ,
719+ Let => ident { name : 49 , ctxt : 0 } ,
720+ __Log => ident { name : 50 , ctxt : 0 } ,
721+ Loop => ident { name : 51 , ctxt : 0 } ,
722+ Match => ident { name : 52 , ctxt : 0 } ,
723+ Mod => ident { name : 53 , ctxt : 0 } ,
724+ Mut => ident { name : 54 , ctxt : 0 } ,
725+ Once => ident { name : 55 , ctxt : 0 } ,
726+ Priv => ident { name : 56 , ctxt : 0 } ,
727+ Pub => ident { name : 57 , ctxt : 0 } ,
728+ Pure => ident { name : 58 , ctxt : 0 } ,
729+ Ref => ident { name : 59 , ctxt : 0 } ,
730+ Return => ident { name : 60 , ctxt : 0 } ,
731+ Static => ident { name : 29 , ctxt : 0 } ,
732+ Self => ident { name : 8 , ctxt : 0 } ,
733+ Struct => ident { name : 61 , ctxt : 0 } ,
734+ Super => ident { name : 62 , ctxt : 0 } ,
735+ True => ident { name : 63 , ctxt : 0 } ,
736+ Trait => ident { name : 64 , ctxt : 0 } ,
737+ Type => ident { name : 65 , ctxt : 0 } ,
738+ Unsafe => ident { name : 66 , ctxt : 0 } ,
739+ Use => ident { name : 67 , ctxt : 0 } ,
740+ While => ident { name : 68 , ctxt : 0 } ,
741+ Be => ident { name : 69 , ctxt : 0 } ,
742+ }
743+ }
744+ #[ cfg( not( stage0) ) ]
745+ pub fn to_ident ( & self ) -> ident {
746+ match * self {
747+ As => ident { name : 35 , ctxt : 0 } ,
748+ Break => ident { name : 36 , ctxt : 0 } ,
749+ Const => ident { name : 37 , ctxt : 0 } ,
750+ Copy => ident { name : 38 , ctxt : 0 } ,
751+ Do => ident { name : 39 , ctxt : 0 } ,
752+ Else => ident { name : 40 , ctxt : 0 } ,
753+ Enum => ident { name : 41 , ctxt : 0 } ,
754+ Extern => ident { name : 42 , ctxt : 0 } ,
755+ False => ident { name : 43 , ctxt : 0 } ,
756+ Fn => ident { name : 44 , ctxt : 0 } ,
757+ For => ident { name : 45 , ctxt : 0 } ,
758+ If => ident { name : 46 , ctxt : 0 } ,
759+ Impl => ident { name : 47 , ctxt : 0 } ,
760+ Let => ident { name : 48 , ctxt : 0 } ,
761+ __Log => ident { name : 49 , ctxt : 0 } ,
762+ Loop => ident { name : 50 , ctxt : 0 } ,
763+ Match => ident { name : 51 , ctxt : 0 } ,
764+ Mod => ident { name : 52 , ctxt : 0 } ,
765+ Mut => ident { name : 53 , ctxt : 0 } ,
766+ Once => ident { name : 54 , ctxt : 0 } ,
767+ Priv => ident { name : 55 , ctxt : 0 } ,
768+ Pub => ident { name : 56 , ctxt : 0 } ,
769+ Pure => ident { name : 57 , ctxt : 0 } ,
770+ Ref => ident { name : 58 , ctxt : 0 } ,
771+ Return => ident { name : 59 , ctxt : 0 } ,
772+ Static => ident { name : 29 , ctxt : 0 } ,
773+ Self => ident { name : 8 , ctxt : 0 } ,
774+ Struct => ident { name : 60 , ctxt : 0 } ,
775+ Super => ident { name : 61 , ctxt : 0 } ,
776+ True => ident { name : 62 , ctxt : 0 } ,
777+ Trait => ident { name : 63 , ctxt : 0 } ,
778+ Type => ident { name : 64 , ctxt : 0 } ,
779+ Unsafe => ident { name : 65 , ctxt : 0 } ,
780+ Use => ident { name : 66 , ctxt : 0 } ,
781+ While => ident { name : 67 , ctxt : 0 } ,
782+ Be => ident { name : 68 , ctxt : 0 } ,
653783 }
654784 }
655785 }
@@ -662,6 +792,7 @@ pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
662792 }
663793}
664794
795+ #[ cfg( stage0) ]
665796pub fn is_any_keyword ( tok : & Token ) -> bool {
666797 match * tok {
667798 token:: IDENT ( sid, false ) => match sid. name {
@@ -672,6 +803,18 @@ pub fn is_any_keyword(tok: &Token) -> bool {
672803 }
673804}
674805
806+ #[ cfg( not( stage0) ) ]
807+ pub fn is_any_keyword ( tok : & Token ) -> bool {
808+ match * tok {
809+ token:: IDENT ( sid, false ) => match sid. name {
810+ 8 | 29 | 35 .. 68 => true ,
811+ _ => false ,
812+ } ,
813+ _ => false
814+ }
815+ }
816+
817+ #[ cfg( stage0) ]
675818pub fn is_strict_keyword ( tok : & Token ) -> bool {
676819 match * tok {
677820 token:: IDENT ( sid, false ) => match sid. name {
@@ -682,6 +825,18 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
682825 }
683826}
684827
828+ #[ cfg( not( stage0) ) ]
829+ pub fn is_strict_keyword ( tok : & Token ) -> bool {
830+ match * tok {
831+ token:: IDENT ( sid, false ) => match sid. name {
832+ 8 | 29 | 35 .. 67 => true ,
833+ _ => false ,
834+ } ,
835+ _ => false ,
836+ }
837+ }
838+
839+ #[ cfg( stage0) ]
685840pub fn is_reserved_keyword ( tok : & Token ) -> bool {
686841 match * tok {
687842 token:: IDENT ( sid, false ) => match sid. name {
@@ -692,6 +847,18 @@ pub fn is_reserved_keyword(tok: &Token) -> bool {
692847 }
693848}
694849
850+ #[ cfg( not( stage0) ) ]
851+ pub fn is_reserved_keyword ( tok : & Token ) -> bool {
852+ match * tok {
853+ token:: IDENT ( sid, false ) => match sid. name {
854+ 68 => true ,
855+ _ => false ,
856+ } ,
857+ _ => false ,
858+ }
859+ }
860+
861+
695862#[ cfg( test) ]
696863mod test {
697864 use super :: * ;
0 commit comments