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

Side by Side Diff: src/preparser.cc

Issue 1429983002: [es6] early error when Identifier is an escaped reserved word (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Bunch of comments addressed + mozilla/test262 statuses updated Created 5 years, 1 month 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 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 149
150 PreParserExpression PreParserTraits::ParseClassLiteral( 150 PreParserExpression PreParserTraits::ParseClassLiteral(
151 PreParserIdentifier name, Scanner::Location class_name_location, 151 PreParserIdentifier name, Scanner::Location class_name_location,
152 bool name_is_strict_reserved, int pos, bool* ok) { 152 bool name_is_strict_reserved, int pos, bool* ok) {
153 return pre_parser_->ParseClassLiteral(name, class_name_location, 153 return pre_parser_->ParseClassLiteral(name, class_name_location,
154 name_is_strict_reserved, pos, ok); 154 name_is_strict_reserved, pos, ok);
155 } 155 }
156 156
157 157
158 #define CHECK_OK ok); \
159 if (!*ok) return Statement::Default(); \
160 ((void)0
161 #define DUMMY ) // to make indentation work
162 #undef DUMMY
163
164
158 // Preparsing checks a JavaScript program and emits preparse-data that helps 165 // Preparsing checks a JavaScript program and emits preparse-data that helps
159 // a later parsing to be faster. 166 // a later parsing to be faster.
160 // See preparser-data.h for the data. 167 // See preparser-data.h for the data.
161 168
162 // The PreParser checks that the syntax follows the grammar for JavaScript, 169 // The PreParser checks that the syntax follows the grammar for JavaScript,
163 // and collects some information about the program along the way. 170 // and collects some information about the program along the way.
164 // The grammar check is only performed in order to understand the program 171 // The grammar check is only performed in order to understand the program
165 // sufficiently to deduce some information about it, that can be used 172 // sufficiently to deduce some information about it, that can be used
166 // to speed up later parsing. Finding errors is not the goal of pre-parsing, 173 // to speed up later parsing. Finding errors is not the goal of pre-parsing,
167 // rather it is to speed up properly written and correct programs. 174 // rather it is to speed up properly written and correct programs.
(...skipping 27 matching lines...) Expand all
195 case Token::CONST: 202 case Token::CONST:
196 if (allow_const()) { 203 if (allow_const()) {
197 return ParseVariableStatement(kStatementListItem, ok); 204 return ParseVariableStatement(kStatementListItem, ok);
198 } 205 }
199 break; 206 break;
200 case Token::LET: 207 case Token::LET:
201 if (IsNextLetKeyword()) { 208 if (IsNextLetKeyword()) {
202 return ParseVariableStatement(kStatementListItem, ok); 209 return ParseVariableStatement(kStatementListItem, ok);
203 } 210 }
204 break; 211 break;
212 case Token::IDENTIFIER:
213 CheckNextEscapedKeyword(CHECK_OK);
214 break;
205 default: 215 default:
206 break; 216 break;
207 } 217 }
208 return ParseStatement(ok); 218 return ParseStatement(ok);
209 } 219 }
210 220
211 221
212 void PreParser::ParseStatementList(int end_token, bool* ok, 222 void PreParser::ParseStatementList(int end_token, bool* ok,
213 Scanner::BookmarkScope* bookmark) { 223 Scanner::BookmarkScope* bookmark) {
214 // SourceElements :: 224 // SourceElements ::
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (count_statements > kLazyParseTrialLimit) { 307 if (count_statements > kLazyParseTrialLimit) {
298 bookmark->Reset(); 308 bookmark->Reset();
299 return; 309 return;
300 } 310 }
301 maybe_reset = false; 311 maybe_reset = false;
302 } 312 }
303 } 313 }
304 } 314 }
305 315
306 316
307 #define CHECK_OK ok); \
308 if (!*ok) return Statement::Default(); \
309 ((void)0
310 #define DUMMY ) // to make indentation work
311 #undef DUMMY
312
313
314 PreParser::Statement PreParser::ParseStatement(bool* ok) { 317 PreParser::Statement PreParser::ParseStatement(bool* ok) {
315 // Statement :: 318 // Statement ::
316 // EmptyStatement 319 // EmptyStatement
317 // ... 320 // ...
318 321
319 if (peek() == Token::SEMICOLON) { 322 if (peek() == Token::SEMICOLON) {
320 Next(); 323 Next();
321 return Statement::Default(); 324 return Statement::Default();
322 } 325 }
323 return ParseSubStatement(ok); 326 return ParseSubStatement(ok);
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 Expect(Token::RBRACE, CHECK_OK); 1257 Expect(Token::RBRACE, CHECK_OK);
1255 return PreParserExpression::Default(); 1258 return PreParserExpression::Default();
1256 } 1259 }
1257 } 1260 }
1258 1261
1259 #undef CHECK_OK 1262 #undef CHECK_OK
1260 1263
1261 1264
1262 } // namespace internal 1265 } // namespace internal
1263 } // namespace v8 1266 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698