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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
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 // Anything excelt '\0' is an octal escape sequence, illegal in strict mode. |
| 113 // Remember the position of octal escape sequences so that better error |
| 114 // can be reported later (in strict mode). |
| 115 if (c != '0' || i > 0) { |
| 116 octal_pos_ = source_pos() - i - 1; // Already advanced |
| 117 } |
112 return x; | 118 return x; |
113 } | 119 } |
114 | 120 |
115 | 121 |
116 // ---------------------------------------------------------------------------- | 122 // ---------------------------------------------------------------------------- |
117 // JavaScriptScanner | 123 // JavaScriptScanner |
118 | 124 |
119 JavaScriptScanner::JavaScriptScanner() : Scanner() {} | 125 JavaScriptScanner::JavaScriptScanner() : Scanner() {} |
120 | 126 |
121 | 127 |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; | 913 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; |
908 break; | 914 break; |
909 case UNMATCHABLE: | 915 case UNMATCHABLE: |
910 break; | 916 break; |
911 } | 917 } |
912 // On fallthrough, it's a failure. | 918 // On fallthrough, it's a failure. |
913 state_ = UNMATCHABLE; | 919 state_ = UNMATCHABLE; |
914 } | 920 } |
915 | 921 |
916 } } // namespace v8::internal | 922 } } // namespace v8::internal |
OLD | NEW |