Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: src/parsing/scanner.cc

Issue 1723313002: [parser] Enforce module-specific identifier restriction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Relax assertion criteria Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 } 1128 }
1129 const bool unicode = true; 1129 const bool unicode = true;
1130 return ScanHexNumber<capture_raw, unicode>(4); 1130 return ScanHexNumber<capture_raw, unicode>(4);
1131 } 1131 }
1132 1132
1133 1133
1134 // ---------------------------------------------------------------------------- 1134 // ----------------------------------------------------------------------------
1135 // Keyword Matcher 1135 // Keyword Matcher
1136 1136
1137 #define KEYWORDS(KEYWORD_GROUP, KEYWORD) \ 1137 #define KEYWORDS(KEYWORD_GROUP, KEYWORD) \
1138 KEYWORD_GROUP('a') \
1139 KEYWORD("await", Token::AWAIT) \
1138 KEYWORD_GROUP('b') \ 1140 KEYWORD_GROUP('b') \
1139 KEYWORD("break", Token::BREAK) \ 1141 KEYWORD("break", Token::BREAK) \
1140 KEYWORD_GROUP('c') \ 1142 KEYWORD_GROUP('c') \
1141 KEYWORD("case", Token::CASE) \ 1143 KEYWORD("case", Token::CASE) \
1142 KEYWORD("catch", Token::CATCH) \ 1144 KEYWORD("catch", Token::CATCH) \
1143 KEYWORD("class", Token::CLASS) \ 1145 KEYWORD("class", Token::CLASS) \
1144 KEYWORD("const", Token::CONST) \ 1146 KEYWORD("const", Token::CONST) \
1145 KEYWORD("continue", Token::CONTINUE) \ 1147 KEYWORD("continue", Token::CONTINUE) \
1146 KEYWORD_GROUP('d') \ 1148 KEYWORD_GROUP('d') \
1147 KEYWORD("debugger", Token::DEBUGGER) \ 1149 KEYWORD("debugger", Token::DEBUGGER) \
1148 KEYWORD("default", Token::DEFAULT) \ 1150 KEYWORD("default", Token::DEFAULT) \
1149 KEYWORD("delete", Token::DELETE) \ 1151 KEYWORD("delete", Token::DELETE) \
1150 KEYWORD("do", Token::DO) \ 1152 KEYWORD("do", Token::DO) \
1151 KEYWORD_GROUP('e') \ 1153 KEYWORD_GROUP('e') \
1152 KEYWORD("else", Token::ELSE) \ 1154 KEYWORD("else", Token::ELSE) \
1153 KEYWORD("enum", Token::FUTURE_RESERVED_WORD) \ 1155 KEYWORD("enum", Token::ENUM) \
1154 KEYWORD("export", Token::EXPORT) \ 1156 KEYWORD("export", Token::EXPORT) \
1155 KEYWORD("extends", Token::EXTENDS) \ 1157 KEYWORD("extends", Token::EXTENDS) \
1156 KEYWORD_GROUP('f') \ 1158 KEYWORD_GROUP('f') \
1157 KEYWORD("false", Token::FALSE_LITERAL) \ 1159 KEYWORD("false", Token::FALSE_LITERAL) \
1158 KEYWORD("finally", Token::FINALLY) \ 1160 KEYWORD("finally", Token::FINALLY) \
1159 KEYWORD("for", Token::FOR) \ 1161 KEYWORD("for", Token::FOR) \
1160 KEYWORD("function", Token::FUNCTION) \ 1162 KEYWORD("function", Token::FUNCTION) \
1161 KEYWORD_GROUP('i') \ 1163 KEYWORD_GROUP('i') \
1162 KEYWORD("if", Token::IF) \ 1164 KEYWORD("if", Token::IF) \
1163 KEYWORD("implements", Token::FUTURE_STRICT_RESERVED_WORD) \ 1165 KEYWORD("implements", Token::FUTURE_STRICT_RESERVED_WORD) \
(...skipping 25 matching lines...) Expand all
1189 KEYWORD("typeof", Token::TYPEOF) \ 1191 KEYWORD("typeof", Token::TYPEOF) \
1190 KEYWORD_GROUP('v') \ 1192 KEYWORD_GROUP('v') \
1191 KEYWORD("var", Token::VAR) \ 1193 KEYWORD("var", Token::VAR) \
1192 KEYWORD("void", Token::VOID) \ 1194 KEYWORD("void", Token::VOID) \
1193 KEYWORD_GROUP('w') \ 1195 KEYWORD_GROUP('w') \
1194 KEYWORD("while", Token::WHILE) \ 1196 KEYWORD("while", Token::WHILE) \
1195 KEYWORD("with", Token::WITH) \ 1197 KEYWORD("with", Token::WITH) \
1196 KEYWORD_GROUP('y') \ 1198 KEYWORD_GROUP('y') \
1197 KEYWORD("yield", Token::YIELD) 1199 KEYWORD("yield", Token::YIELD)
1198 1200
1199
1200 static Token::Value KeywordOrIdentifierToken(const uint8_t* input, 1201 static Token::Value KeywordOrIdentifierToken(const uint8_t* input,
1201 int input_length, bool escaped) { 1202 int input_length, bool escaped) {
1202 DCHECK(input_length >= 1); 1203 DCHECK(input_length >= 1);
1203 const int kMinLength = 2; 1204 const int kMinLength = 2;
1204 const int kMaxLength = 10; 1205 const int kMaxLength = 10;
1205 if (input_length < kMinLength || input_length > kMaxLength) { 1206 if (input_length < kMinLength || input_length > kMaxLength) {
1206 return Token::IDENTIFIER; 1207 return Token::IDENTIFIER;
1207 } 1208 }
1208 switch (input[0]) { 1209 switch (input[0]) {
1209 default: 1210 default:
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); 1687 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u));
1687 } 1688 }
1688 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); 1689 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f));
1689 1690
1690 backing_store_.AddBlock(bytes); 1691 backing_store_.AddBlock(bytes);
1691 return backing_store_.EndSequence().start(); 1692 return backing_store_.EndSequence().start();
1692 } 1693 }
1693 1694
1694 } // namespace internal 1695 } // namespace internal
1695 } // namespace v8 1696 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.cc ('k') | src/parsing/token.h » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698