OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 } | 90 } |
91 x = x * 16 + d; | 91 x = x * 16 + d; |
92 Advance(); | 92 Advance(); |
93 } | 93 } |
94 | 94 |
95 return x; | 95 return x; |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 // Octal escapes of the forms '\0xx' and '\xxx' are not a part of | 99 // Octal escapes of the forms '\0xx' and '\xxx' are not a part of |
100 // ECMA-262. Other JS VMs support them. | 100 // ECMA-262. Other JS VMs support them. |
Lasse Reichstein
2011/01/31 06:05:19
Add comment here (or, preferably, at the declarati
Martin Maly
2011/01/31 22:44:06
Done.
| |
101 uc32 Scanner::ScanOctalEscape(uc32 c, int length) { | 101 uc32 Scanner::ScanOctalEscape(uc32 c, int length) { |
102 octal_pos_ = source_pos() - 1; // Already advanced | |
103 uc32 x = c - '0'; | 102 uc32 x = c - '0'; |
104 for (int i = 0; i < length; i++) { | 103 int i = 0; |
104 for (; i < length; i++) { | |
105 int d = c0_ - '0'; | 105 int d = c0_ - '0'; |
106 if (d < 0 || d > 7) break; | 106 if (d < 0 || d > 7) break; |
107 int nx = x * 8 + d; | 107 int nx = x * 8 + d; |
108 if (nx >= 256) break; | 108 if (nx >= 256) break; |
109 x = nx; | 109 x = nx; |
110 Advance(); | 110 Advance(); |
111 } | 111 } |
112 // Allow \0 only. Rest are octal escapes, illegal in strict mode. | |
Lasse Reichstein
2011/01/31 06:05:19
We "allow" everything (we don't reject anything he
Martin Maly
2011/01/31 22:44:06
Done.
| |
113 if (c != '\0' || i > 0) { | |
114 octal_pos_ = source_pos() - i - 1; // Already advanced | |
115 } | |
112 return x; | 116 return x; |
113 } | 117 } |
114 | 118 |
115 | 119 |
116 // ---------------------------------------------------------------------------- | 120 // ---------------------------------------------------------------------------- |
117 // JavaScriptScanner | 121 // JavaScriptScanner |
118 | 122 |
119 JavaScriptScanner::JavaScriptScanner() : Scanner() {} | 123 JavaScriptScanner::JavaScriptScanner() : Scanner() {} |
120 | 124 |
121 | 125 |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; | 911 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; |
908 break; | 912 break; |
909 case UNMATCHABLE: | 913 case UNMATCHABLE: |
910 break; | 914 break; |
911 } | 915 } |
912 // On fallthrough, it's a failure. | 916 // On fallthrough, it's a failure. |
913 state_ = UNMATCHABLE; | 917 state_ = UNMATCHABLE; |
914 } | 918 } |
915 | 919 |
916 } } // namespace v8::internal | 920 } } // namespace v8::internal |
OLD | NEW |