OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
6 | 6 |
7 #include "src/parsing/scanner.h" | 7 #include "src/parsing/scanner.h" |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 int nx = x * 8 + d; | 1038 int nx = x * 8 + d; |
1039 if (nx >= 256) break; | 1039 if (nx >= 256) break; |
1040 x = nx; | 1040 x = nx; |
1041 Advance<capture_raw>(); | 1041 Advance<capture_raw>(); |
1042 } | 1042 } |
1043 // Anything except '\0' is an octal escape sequence, illegal in strict mode. | 1043 // Anything except '\0' is an octal escape sequence, illegal in strict mode. |
1044 // Remember the position of octal escape sequences so that an error | 1044 // Remember the position of octal escape sequences so that an error |
1045 // can be reported later (in strict mode). | 1045 // can be reported later (in strict mode). |
1046 // We don't report the error immediately, because the octal escape can | 1046 // We don't report the error immediately, because the octal escape can |
1047 // occur before the "use strict" directive. | 1047 // occur before the "use strict" directive. |
1048 if (c != '0' || i > 0 || c0_ == '8' || c0_ == '9') { | 1048 if (c != '0' || i > 0) { |
1049 octal_pos_ = Location(source_pos() - i - 1, source_pos() - 1); | 1049 octal_pos_ = Location(source_pos() - i - 1, source_pos() - 1); |
1050 octal_message_ = MessageTemplate::kStrictOctalEscape; | 1050 octal_message_ = MessageTemplate::kStrictOctalEscape; |
1051 } | 1051 } |
1052 return x; | 1052 return x; |
1053 } | 1053 } |
1054 | 1054 |
1055 | 1055 |
1056 Token::Value Scanner::ScanString() { | 1056 Token::Value Scanner::ScanString() { |
1057 uc32 quote = c0_; | 1057 uc32 quote = c0_; |
1058 Advance<false, false>(); // consume quote | 1058 Advance<false, false>(); // consume quote |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 // 2, reset the source to the desired position, | 1820 // 2, reset the source to the desired position, |
1821 source_->Seek(position); | 1821 source_->Seek(position); |
1822 // 3, re-scan, by scanning the look-ahead char + 1 token (next_). | 1822 // 3, re-scan, by scanning the look-ahead char + 1 token (next_). |
1823 c0_ = source_->Advance(); | 1823 c0_ = source_->Advance(); |
1824 Next(); | 1824 Next(); |
1825 DCHECK_EQ(next_.location.beg_pos, static_cast<int>(position)); | 1825 DCHECK_EQ(next_.location.beg_pos, static_cast<int>(position)); |
1826 } | 1826 } |
1827 | 1827 |
1828 } // namespace internal | 1828 } // namespace internal |
1829 } // namespace v8 | 1829 } // namespace v8 |
OLD | NEW |