OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 { "break", KEYWORD_PREFIX, Token::BREAK }, | 792 { "break", KEYWORD_PREFIX, Token::BREAK }, |
793 { NULL, C, Token::ILLEGAL }, | 793 { NULL, C, Token::ILLEGAL }, |
794 { NULL, D, Token::ILLEGAL }, | 794 { NULL, D, Token::ILLEGAL }, |
795 { NULL, E, Token::ILLEGAL }, | 795 { NULL, E, Token::ILLEGAL }, |
796 { NULL, F, Token::ILLEGAL }, | 796 { NULL, F, Token::ILLEGAL }, |
797 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 797 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
798 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 798 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
799 { NULL, I, Token::ILLEGAL }, | 799 { NULL, I, Token::ILLEGAL }, |
800 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 800 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
801 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 801 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
802 { "let", KEYWORD_PREFIX, Token::FUTURE_RESERVED_WORD }, | 802 { "let", KEYWORD_PREFIX, Token::FUTURE_STRICT_RESERVED_WORD }, |
803 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 803 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
804 { NULL, N, Token::ILLEGAL }, | 804 { NULL, N, Token::ILLEGAL }, |
805 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 805 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
806 { NULL, P, Token::ILLEGAL }, | 806 { NULL, P, Token::ILLEGAL }, |
807 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 807 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
808 { "return", KEYWORD_PREFIX, Token::RETURN }, | 808 { "return", KEYWORD_PREFIX, Token::RETURN }, |
809 { NULL, S, Token::ILLEGAL }, | 809 { NULL, S, Token::ILLEGAL }, |
810 { NULL, T, Token::ILLEGAL }, | 810 { NULL, T, Token::ILLEGAL }, |
811 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 811 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
812 { NULL, V, Token::ILLEGAL }, | 812 { NULL, V, Token::ILLEGAL }, |
813 { NULL, W, Token::ILLEGAL }, | 813 { NULL, W, Token::ILLEGAL }, |
814 { NULL, UNMATCHABLE, Token::ILLEGAL }, | 814 { NULL, UNMATCHABLE, Token::ILLEGAL }, |
815 { "yield", KEYWORD_PREFIX, Token::FUTURE_RESERVED_WORD } | 815 { "yield", KEYWORD_PREFIX, Token::FUTURE_STRICT_RESERVED_WORD } |
816 }; | 816 }; |
817 | 817 |
818 | 818 |
819 void KeywordMatcher::Step(unibrow::uchar input) { | 819 void KeywordMatcher::Step(unibrow::uchar input) { |
820 switch (state_) { | 820 switch (state_) { |
821 case INITIAL: { | 821 case INITIAL: { |
822 // matching the first character is the only state with significant fanout. | 822 // matching the first character is the only state with significant fanout. |
823 // Match only lower-case letters in range 'b'..'y'. | 823 // Match only lower-case letters in range 'b'..'y'. |
824 unsigned int offset = input - kFirstCharRangeMin; | 824 unsigned int offset = input - kFirstCharRangeMin; |
825 if (offset < kFirstCharRangeLength) { | 825 if (offset < kFirstCharRangeLength) { |
(...skipping 16 matching lines...) Expand all Loading... |
842 } | 842 } |
843 return; | 843 return; |
844 } | 844 } |
845 break; | 845 break; |
846 case KEYWORD_MATCHED: | 846 case KEYWORD_MATCHED: |
847 token_ = Token::IDENTIFIER; | 847 token_ = Token::IDENTIFIER; |
848 break; | 848 break; |
849 case C: | 849 case C: |
850 if (MatchState(input, 'a', CA)) return; | 850 if (MatchState(input, 'a', CA)) return; |
851 if (MatchKeywordStart(input, "class", 1, | 851 if (MatchKeywordStart(input, "class", 1, |
852 Token::FUTURE_RESERVED_WORD)) return; | 852 Token::FUTURE_RESERVED_WORD)) return; |
853 if (MatchState(input, 'o', CO)) return; | 853 if (MatchState(input, 'o', CO)) return; |
854 break; | 854 break; |
855 case CA: | 855 case CA: |
856 if (MatchKeywordStart(input, "case", 2, Token::CASE)) return; | 856 if (MatchKeywordStart(input, "case", 2, Token::CASE)) return; |
857 if (MatchKeywordStart(input, "catch", 2, Token::CATCH)) return; | 857 if (MatchKeywordStart(input, "catch", 2, Token::CATCH)) return; |
858 break; | 858 break; |
859 case CO: | 859 case CO: |
860 if (MatchState(input, 'n', CON)) return; | 860 if (MatchState(input, 'n', CON)) return; |
861 break; | 861 break; |
862 case CON: | 862 case CON: |
863 if (MatchKeywordStart(input, "const", 3, Token::CONST)) return; | 863 if (MatchKeywordStart(input, "const", 3, Token::CONST)) return; |
864 if (MatchKeywordStart(input, "continue", 3, Token::CONTINUE)) return; | 864 if (MatchKeywordStart(input, "continue", 3, Token::CONTINUE)) return; |
865 break; | 865 break; |
866 case D: | 866 case D: |
867 if (MatchState(input, 'e', DE)) return; | 867 if (MatchState(input, 'e', DE)) return; |
868 if (MatchKeyword(input, 'o', KEYWORD_MATCHED, Token::DO)) return; | 868 if (MatchKeyword(input, 'o', KEYWORD_MATCHED, Token::DO)) return; |
869 break; | 869 break; |
870 case DE: | 870 case DE: |
871 if (MatchKeywordStart(input, "debugger", 2, Token::DEBUGGER)) return; | 871 if (MatchKeywordStart(input, "debugger", 2, Token::DEBUGGER)) return; |
872 if (MatchKeywordStart(input, "default", 2, Token::DEFAULT)) return; | 872 if (MatchKeywordStart(input, "default", 2, Token::DEFAULT)) return; |
873 if (MatchKeywordStart(input, "delete", 2, Token::DELETE)) return; | 873 if (MatchKeywordStart(input, "delete", 2, Token::DELETE)) return; |
874 break; | 874 break; |
875 case E: | 875 case E: |
876 if (MatchKeywordStart(input, "else", 1, Token::ELSE)) return; | 876 if (MatchKeywordStart(input, "else", 1, Token::ELSE)) return; |
877 if (MatchKeywordStart(input, "enum", 1, | 877 if (MatchKeywordStart(input, "enum", 1, |
878 Token::FUTURE_RESERVED_WORD)) return; | 878 Token::FUTURE_RESERVED_WORD)) return; |
879 if (MatchState(input, 'x', EX)) return; | 879 if (MatchState(input, 'x', EX)) return; |
880 break; | 880 break; |
881 case EX: | 881 case EX: |
882 if (MatchKeywordStart(input, "export", 2, | 882 if (MatchKeywordStart(input, "export", 2, |
883 Token::FUTURE_RESERVED_WORD)) return; | 883 Token::FUTURE_RESERVED_WORD)) return; |
884 if (MatchKeywordStart(input, "extends", 2, | 884 if (MatchKeywordStart(input, "extends", 2, |
885 Token::FUTURE_RESERVED_WORD)) return; | 885 Token::FUTURE_RESERVED_WORD)) return; |
886 break; | 886 break; |
887 case F: | 887 case F: |
888 if (MatchKeywordStart(input, "false", 1, Token::FALSE_LITERAL)) return; | 888 if (MatchKeywordStart(input, "false", 1, Token::FALSE_LITERAL)) return; |
889 if (MatchKeywordStart(input, "finally", 1, Token::FINALLY)) return; | 889 if (MatchKeywordStart(input, "finally", 1, Token::FINALLY)) return; |
890 if (MatchKeywordStart(input, "for", 1, Token::FOR)) return; | 890 if (MatchKeywordStart(input, "for", 1, Token::FOR)) return; |
891 if (MatchKeywordStart(input, "function", 1, Token::FUNCTION)) return; | 891 if (MatchKeywordStart(input, "function", 1, Token::FUNCTION)) return; |
892 break; | 892 break; |
893 case I: | 893 case I: |
894 if (MatchKeyword(input, 'f', KEYWORD_MATCHED, Token::IF)) return; | 894 if (MatchKeyword(input, 'f', KEYWORD_MATCHED, Token::IF)) return; |
895 if (MatchState(input, 'm', IM)) return; | 895 if (MatchState(input, 'm', IM)) return; |
896 if (MatchKeyword(input, 'n', IN, Token::IN)) return; | 896 if (MatchKeyword(input, 'n', IN, Token::IN)) return; |
897 break; | 897 break; |
898 case IM: | 898 case IM: |
899 if (MatchState(input, 'p', IMP)) return; | 899 if (MatchState(input, 'p', IMP)) return; |
900 break; | 900 break; |
901 case IMP: | 901 case IMP: |
902 if (MatchKeywordStart(input, "implements", 3, | 902 if (MatchKeywordStart(input, "implements", 3, |
903 Token::FUTURE_RESERVED_WORD )) return; | 903 Token::FUTURE_STRICT_RESERVED_WORD )) return; |
904 if (MatchKeywordStart(input, "import", 3, | 904 if (MatchKeywordStart(input, "import", 3, |
905 Token::FUTURE_RESERVED_WORD)) return; | 905 Token::FUTURE_RESERVED_WORD)) return; |
906 break; | 906 break; |
907 case IN: | 907 case IN: |
908 token_ = Token::IDENTIFIER; | 908 token_ = Token::IDENTIFIER; |
909 if (MatchKeywordStart(input, "interface", 2, | 909 if (MatchKeywordStart(input, "interface", 2, |
910 Token::FUTURE_RESERVED_WORD)) return; | 910 Token::FUTURE_STRICT_RESERVED_WORD)) return; |
911 if (MatchKeywordStart(input, "instanceof", 2, Token::INSTANCEOF)) return; | 911 if (MatchKeywordStart(input, "instanceof", 2, Token::INSTANCEOF)) return; |
912 break; | 912 break; |
913 case N: | 913 case N: |
914 if (MatchKeywordStart(input, "new", 1, Token::NEW)) return; | 914 if (MatchKeywordStart(input, "new", 1, Token::NEW)) return; |
915 if (MatchKeywordStart(input, "null", 1, Token::NULL_LITERAL)) return; | 915 if (MatchKeywordStart(input, "null", 1, Token::NULL_LITERAL)) return; |
916 break; | 916 break; |
917 case P: | 917 case P: |
918 if (MatchKeywordStart(input, "package", 1, | 918 if (MatchKeywordStart(input, "package", 1, |
919 Token::FUTURE_RESERVED_WORD)) return; | 919 Token::FUTURE_STRICT_RESERVED_WORD)) return; |
920 if (MatchState(input, 'r', PR)) return; | 920 if (MatchState(input, 'r', PR)) return; |
921 if (MatchKeywordStart(input, "public", 1, | 921 if (MatchKeywordStart(input, "public", 1, |
922 Token::FUTURE_RESERVED_WORD)) return; | 922 Token::FUTURE_STRICT_RESERVED_WORD)) return; |
923 break; | 923 break; |
924 case PR: | 924 case PR: |
925 if (MatchKeywordStart(input, "private", 2, | 925 if (MatchKeywordStart(input, "private", 2, |
926 Token::FUTURE_RESERVED_WORD)) return; | 926 Token::FUTURE_STRICT_RESERVED_WORD)) return; |
927 if (MatchKeywordStart(input, "protected", 2, | 927 if (MatchKeywordStart(input, "protected", 2, |
928 Token::FUTURE_RESERVED_WORD)) return; | 928 Token::FUTURE_STRICT_RESERVED_WORD)) return; |
929 break; | 929 break; |
930 case S: | 930 case S: |
931 if (MatchKeywordStart(input, "static", 1, | 931 if (MatchKeywordStart(input, "static", 1, |
932 Token::FUTURE_RESERVED_WORD)) return; | 932 Token::FUTURE_STRICT_RESERVED_WORD)) return; |
933 if (MatchKeywordStart(input, "super", 1, | 933 if (MatchKeywordStart(input, "super", 1, |
934 Token::FUTURE_RESERVED_WORD)) return; | 934 Token::FUTURE_RESERVED_WORD)) return; |
935 if (MatchKeywordStart(input, "switch", 1, | 935 if (MatchKeywordStart(input, "switch", 1, |
936 Token::SWITCH)) return; | 936 Token::SWITCH)) return; |
937 break; | 937 break; |
938 case T: | 938 case T: |
939 if (MatchState(input, 'h', TH)) return; | 939 if (MatchState(input, 'h', TH)) return; |
940 if (MatchState(input, 'r', TR)) return; | 940 if (MatchState(input, 'r', TR)) return; |
941 if (MatchKeywordStart(input, "typeof", 1, Token::TYPEOF)) return; | 941 if (MatchKeywordStart(input, "typeof", 1, Token::TYPEOF)) return; |
942 break; | 942 break; |
943 case TH: | 943 case TH: |
944 if (MatchKeywordStart(input, "this", 2, Token::THIS)) return; | 944 if (MatchKeywordStart(input, "this", 2, Token::THIS)) return; |
945 if (MatchKeywordStart(input, "throw", 2, Token::THROW)) return; | 945 if (MatchKeywordStart(input, "throw", 2, Token::THROW)) return; |
946 break; | 946 break; |
(...skipping 10 matching lines...) Expand all Loading... |
957 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; | 957 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; |
958 break; | 958 break; |
959 case UNMATCHABLE: | 959 case UNMATCHABLE: |
960 break; | 960 break; |
961 } | 961 } |
962 // On fallthrough, it's a failure. | 962 // On fallthrough, it's a failure. |
963 state_ = UNMATCHABLE; | 963 state_ = UNMATCHABLE; |
964 } | 964 } |
965 | 965 |
966 } } // namespace v8::internal | 966 } } // namespace v8::internal |
OLD | NEW |