Chromium Code Reviews| 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 } | 781 } |
| 782 literal.Complete(); | 782 literal.Complete(); |
| 783 | 783 |
| 784 next_.location.end_pos = source_pos() - 1; | 784 next_.location.end_pos = source_pos() - 1; |
| 785 return true; | 785 return true; |
| 786 } | 786 } |
| 787 | 787 |
| 788 // ---------------------------------------------------------------------------- | 788 // ---------------------------------------------------------------------------- |
| 789 // Keyword Matcher | 789 // Keyword Matcher |
| 790 | 790 |
| 791 KeywordMatcher::FirstState KeywordMatcher::first_states_[] = { | 791 KeywordMatcher::FirstState KeywordMatcher::first_states_[] = { |
|
Lasse Reichstein
2011/06/22 20:29:33
The declaration of KeywordMatcher in scanner-base.
Steven
2011/06/24 11:34:59
Done.
| |
| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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; |
|
Lasse Reichstein
2011/06/22 20:29:33
Indent to align with "input". Ditto for other case
Steven
2011/06/24 11:34:59
Done.
| |
| 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; |
| (...skipping 14 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 |