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

Side by Side Diff: src/preparser.cc

Issue 7616009: Parse harmony let declarations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "../include/v8stdint.h" 28 #include "../include/v8stdint.h"
29 #include "unicode.h" 29 #include "unicode.h"
30 #include "globals.h" 30 #include "globals.h"
31 #include "checks.h" 31 #include "checks.h"
32 #include "allocation.h" 32 #include "allocation.h"
33 #include "flags.h"
33 #include "utils.h" 34 #include "utils.h"
34 #include "list.h" 35 #include "list.h"
35 36
36 #include "scanner-base.h" 37 #include "scanner-base.h"
37 #include "preparse-data-format.h" 38 #include "preparse-data-format.h"
38 #include "preparse-data.h" 39 #include "preparse-data.h"
39 #include "preparser.h" 40 #include "preparser.h"
40 41
41 #include "conversions-inl.h" 42 #include "conversions-inl.h"
42 43
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 "unexpected_token_number", NULL); 78 "unexpected_token_number", NULL);
78 case i::Token::STRING: 79 case i::Token::STRING:
79 return ReportMessageAt(source_location.beg_pos, source_location.end_pos, 80 return ReportMessageAt(source_location.beg_pos, source_location.end_pos,
80 "unexpected_token_string", NULL); 81 "unexpected_token_string", NULL);
81 case i::Token::IDENTIFIER: 82 case i::Token::IDENTIFIER:
82 return ReportMessageAt(source_location.beg_pos, source_location.end_pos, 83 return ReportMessageAt(source_location.beg_pos, source_location.end_pos,
83 "unexpected_token_identifier", NULL); 84 "unexpected_token_identifier", NULL);
84 case i::Token::FUTURE_RESERVED_WORD: 85 case i::Token::FUTURE_RESERVED_WORD:
85 return ReportMessageAt(source_location.beg_pos, source_location.end_pos, 86 return ReportMessageAt(source_location.beg_pos, source_location.end_pos,
86 "unexpected_reserved", NULL); 87 "unexpected_reserved", NULL);
88 case i::Token::LET:
89 // fallthrough
Lasse Reichstein 2011/08/12 08:08:33 No need to write "fallthrough" if the two case lab
Steven 2011/08/16 09:05:32 The scanner is now producing the correct token bas
87 case i::Token::FUTURE_STRICT_RESERVED_WORD: 90 case i::Token::FUTURE_STRICT_RESERVED_WORD:
88 return ReportMessageAt(source_location.beg_pos, source_location.end_pos, 91 return ReportMessageAt(source_location.beg_pos, source_location.end_pos,
89 "unexpected_strict_reserved", NULL); 92 "unexpected_strict_reserved", NULL);
90 default: 93 default:
91 const char* name = i::Token::String(token); 94 const char* name = i::Token::String(token);
92 ReportMessageAt(source_location.beg_pos, source_location.end_pos, 95 ReportMessageAt(source_location.beg_pos, source_location.end_pos,
93 "unexpected_token", name); 96 "unexpected_token", name);
94 } 97 }
95 } 98 }
96 99
(...skipping 10 matching lines...) Expand all
107 } 110 }
108 111
109 112
110 #define CHECK_OK ok); \ 113 #define CHECK_OK ok); \
111 if (!*ok) return kUnknownSourceElements; \ 114 if (!*ok) return kUnknownSourceElements; \
112 ((void)0 115 ((void)0
113 #define DUMMY ) // to make indentation work 116 #define DUMMY ) // to make indentation work
114 #undef DUMMY 117 #undef DUMMY
115 118
116 119
120 PreParser::Statement PreParser::ParseSourceElement(bool* ok) {
121 switch (peek()) {
122 case i::Token::LET:
123 if (i::FLAG_harmony_block_scoping) {
124 return ParseVariableStatement(true, ok);
125 }
Lasse Reichstein 2011/08/12 08:08:33 Need fallthrough here. Or drop the switch and just
Steven 2011/08/16 09:05:32 Done.
126 default:
127 return ParseStatement(ok);
128 }
129 }
130
131
117 PreParser::SourceElements PreParser::ParseSourceElements(int end_token, 132 PreParser::SourceElements PreParser::ParseSourceElements(int end_token,
118 bool* ok) { 133 bool* ok) {
119 // SourceElements :: 134 // SourceElements ::
120 // (Statement)* <end_token> 135 // (Statement)* <end_token>
121 136
122 bool allow_directive_prologue = true; 137 bool allow_directive_prologue = true;
123 while (peek() != end_token) { 138 while (peek() != end_token) {
124 Statement statement = ParseStatement(CHECK_OK); 139 Statement statement = ParseSourceElement(CHECK_OK);
125 if (allow_directive_prologue) { 140 if (allow_directive_prologue) {
126 if (statement.IsUseStrictLiteral()) { 141 if (statement.IsUseStrictLiteral()) {
127 set_strict_mode(); 142 set_strict_mode();
128 } else if (!statement.IsStringLiteral()) { 143 } else if (!statement.IsStringLiteral()) {
129 allow_directive_prologue = false; 144 allow_directive_prologue = false;
130 } 145 }
131 } 146 }
132 } 147 }
133 return kUnknownSourceElements; 148 return kUnknownSourceElements;
134 } 149 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // trivial labeled break statements 'label: break label' which is 182 // trivial labeled break statements 'label: break label' which is
168 // parsed into an empty statement. 183 // parsed into an empty statement.
169 184
170 // Keep the source position of the statement 185 // Keep the source position of the statement
171 switch (peek()) { 186 switch (peek()) {
172 case i::Token::LBRACE: 187 case i::Token::LBRACE:
173 return ParseBlock(ok); 188 return ParseBlock(ok);
174 189
175 case i::Token::CONST: 190 case i::Token::CONST:
176 case i::Token::VAR: 191 case i::Token::VAR:
177 return ParseVariableStatement(ok); 192 return ParseVariableStatement(false, ok);
178 193
179 case i::Token::SEMICOLON: 194 case i::Token::SEMICOLON:
180 Next(); 195 Next();
181 return Statement::Default(); 196 return Statement::Default();
182 197
183 case i::Token::IF: 198 case i::Token::IF:
184 return ParseIfStatement(ok); 199 return ParseIfStatement(ok);
185 200
186 case i::Token::DO: 201 case i::Token::DO:
187 return ParseDoWhileStatement(ok); 202 return ParseDoWhileStatement(ok);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 PreParser::Statement PreParser::ParseBlock(bool* ok) { 268 PreParser::Statement PreParser::ParseBlock(bool* ok) {
254 // Block :: 269 // Block ::
255 // '{' Statement* '}' 270 // '{' Statement* '}'
256 271
257 // Note that a Block does not introduce a new execution scope! 272 // Note that a Block does not introduce a new execution scope!
258 // (ECMA-262, 3rd, 12.2) 273 // (ECMA-262, 3rd, 12.2)
259 // 274 //
260 Expect(i::Token::LBRACE, CHECK_OK); 275 Expect(i::Token::LBRACE, CHECK_OK);
261 while (peek() != i::Token::RBRACE) { 276 while (peek() != i::Token::RBRACE) {
262 i::Scanner::Location start_location = scanner_->peek_location(); 277 i::Scanner::Location start_location = scanner_->peek_location();
263 Statement statement = ParseStatement(CHECK_OK); 278 Statement statement = ParseSourceElement(CHECK_OK);
264 i::Scanner::Location end_location = scanner_->location(); 279 i::Scanner::Location end_location = scanner_->location();
265 if (strict_mode() && statement.IsFunctionDeclaration()) { 280 if (strict_mode() && statement.IsFunctionDeclaration()) {
266 ReportMessageAt(start_location.beg_pos, end_location.end_pos, 281 ReportMessageAt(start_location.beg_pos, end_location.end_pos,
267 "strict_function", NULL); 282 "strict_function", NULL);
268 *ok = false; 283 *ok = false;
269 return Statement::Default(); 284 return Statement::Default();
270 } 285 }
271 } 286 }
272 Expect(i::Token::RBRACE, ok); 287 Expect(i::Token::RBRACE, ok);
273 return Statement::Default(); 288 return Statement::Default();
274 } 289 }
275 290
276 291
277 PreParser::Statement PreParser::ParseVariableStatement(bool* ok) { 292 PreParser::Statement PreParser::ParseVariableStatement(bool accept_LET,
293 bool* ok) {
278 // VariableStatement :: 294 // VariableStatement ::
279 // VariableDeclarations ';' 295 // VariableDeclarations ';'
280 296
281 Statement result = ParseVariableDeclarations(true, NULL, CHECK_OK); 297 Statement result = ParseVariableDeclarations(accept_LET,
298 true,
299 NULL,
300 CHECK_OK);
282 ExpectSemicolon(CHECK_OK); 301 ExpectSemicolon(CHECK_OK);
283 return result; 302 return result;
284 } 303 }
285 304
286 305
287 // If the variable declaration declares exactly one non-const 306 // If the variable declaration declares exactly one non-const
288 // variable, then *var is set to that variable. In all other cases, 307 // variable, then *var is set to that variable. In all other cases,
289 // *var is untouched; in particular, it is the caller's responsibility 308 // *var is untouched; in particular, it is the caller's responsibility
290 // to initialize it properly. This mechanism is also used for the parsing 309 // to initialize it properly. This mechanism is also used for the parsing
291 // of 'for-in' loops. 310 // of 'for-in' loops.
292 PreParser::Statement PreParser::ParseVariableDeclarations(bool accept_IN, 311 PreParser::Statement PreParser::ParseVariableDeclarations(bool accept_LET,
312 bool accept_IN,
293 int* num_decl, 313 int* num_decl,
294 bool* ok) { 314 bool* ok) {
295 // VariableDeclarations :: 315 // VariableDeclarations ::
296 // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[','] 316 // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[',']
297 317
298 if (peek() == i::Token::VAR) { 318 if (peek() == i::Token::VAR) {
299 Consume(i::Token::VAR); 319 Consume(i::Token::VAR);
300 } else if (peek() == i::Token::CONST) { 320 } else if (peek() == i::Token::CONST) {
301 if (strict_mode()) { 321 if (strict_mode()) {
302 i::Scanner::Location location = scanner_->peek_location(); 322 i::Scanner::Location location = scanner_->peek_location();
303 ReportMessageAt(location.beg_pos, location.end_pos, 323 ReportMessageAt(location.beg_pos, location.end_pos,
304 "strict_const", NULL); 324 "strict_const", NULL);
305 *ok = false; 325 *ok = false;
306 return Statement::Default(); 326 return Statement::Default();
307 } 327 }
308 Consume(i::Token::CONST); 328 Consume(i::Token::CONST);
329 } else if (peek() == i::Token::LET) {
330 if (!accept_LET) {
331 i::Scanner::Location location = scanner_->peek_location();
332 ReportMessageAt(location.beg_pos, location.end_pos,
333 "unprotected_let", NULL);
334 *ok = false;
335 return Statement::Default();
336 }
337 Consume(i::Token::LET);
309 } else { 338 } else {
310 *ok = false; 339 *ok = false;
311 return Statement::Default(); 340 return Statement::Default();
312 } 341 }
313 342
314 // The scope of a variable/const declared anywhere inside a function 343 // The scope of a variable/const declared anywhere inside a function
315 // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). . 344 // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). .
Lasse Reichstein 2011/08/12 08:08:33 This comment seems to be outdated now. And it has
Steven 2011/08/16 09:05:32 Done.
316 int nvars = 0; // the number of variables declared 345 int nvars = 0; // the number of variables declared
317 do { 346 do {
318 // Parse variable name. 347 // Parse variable name.
319 if (nvars > 0) Consume(i::Token::COMMA); 348 if (nvars > 0) Consume(i::Token::COMMA);
320 Identifier identifier = ParseIdentifier(CHECK_OK); 349 Identifier identifier = ParseIdentifier(CHECK_OK);
321 if (strict_mode() && !identifier.IsValidStrictVariable()) { 350 if (strict_mode() && !identifier.IsValidStrictVariable()) {
322 StrictModeIdentifierViolation(scanner_->location(), 351 StrictModeIdentifierViolation(scanner_->location(),
323 "strict_var_name", 352 "strict_var_name",
324 identifier, 353 identifier,
325 ok); 354 ok);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 559 }
531 560
532 561
533 PreParser::Statement PreParser::ParseForStatement(bool* ok) { 562 PreParser::Statement PreParser::ParseForStatement(bool* ok) {
534 // ForStatement :: 563 // ForStatement ::
535 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement 564 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
536 565
537 Expect(i::Token::FOR, CHECK_OK); 566 Expect(i::Token::FOR, CHECK_OK);
538 Expect(i::Token::LPAREN, CHECK_OK); 567 Expect(i::Token::LPAREN, CHECK_OK);
539 if (peek() != i::Token::SEMICOLON) { 568 if (peek() != i::Token::SEMICOLON) {
540 if (peek() == i::Token::VAR || peek() == i::Token::CONST) { 569 if (peek() == i::Token::VAR || peek() == i::Token::CONST ||
570 peek() == i::Token::LET) {
541 int decl_count; 571 int decl_count;
542 ParseVariableDeclarations(false, &decl_count, CHECK_OK); 572 ParseVariableDeclarations(true, false, &decl_count, CHECK_OK);
543 if (peek() == i::Token::IN && decl_count == 1) { 573 if (peek() == i::Token::IN && decl_count == 1) {
544 Expect(i::Token::IN, CHECK_OK); 574 Expect(i::Token::IN, CHECK_OK);
545 ParseExpression(true, CHECK_OK); 575 ParseExpression(true, CHECK_OK);
546 Expect(i::Token::RPAREN, CHECK_OK); 576 Expect(i::Token::RPAREN, CHECK_OK);
547 577
548 ParseStatement(CHECK_OK); 578 ParseStatement(CHECK_OK);
549 return Statement::Default(); 579 return Statement::Default();
550 } 580 }
551 } else { 581 } else {
552 ParseExpression(false, CHECK_OK); 582 ParseExpression(false, CHECK_OK);
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 1018
989 case i::Token::FUTURE_RESERVED_WORD: { 1019 case i::Token::FUTURE_RESERVED_WORD: {
990 Next(); 1020 Next();
991 i::Scanner::Location location = scanner_->location(); 1021 i::Scanner::Location location = scanner_->location();
992 ReportMessageAt(location.beg_pos, location.end_pos, 1022 ReportMessageAt(location.beg_pos, location.end_pos,
993 "reserved_word", NULL); 1023 "reserved_word", NULL);
994 *ok = false; 1024 *ok = false;
995 return Expression::Default(); 1025 return Expression::Default();
996 } 1026 }
997 1027
1028 case i::Token::LET:
1029 if (i::FLAG_harmony_block_scoping) {
1030 Next();
1031 i::Scanner::Location location = scanner_->location();
1032 ReportMessageAt(location.beg_pos, location.end_pos,
1033 "unexpected_token", NULL);
1034 *ok = false;
1035 return Expression::Default();
1036 }
1037 // FALLTHROUGH
998 case i::Token::FUTURE_STRICT_RESERVED_WORD: 1038 case i::Token::FUTURE_STRICT_RESERVED_WORD:
999 if (strict_mode()) { 1039 if (strict_mode()) {
1000 Next(); 1040 Next();
1001 i::Scanner::Location location = scanner_->location(); 1041 i::Scanner::Location location = scanner_->location();
1002 ReportMessageAt(location.beg_pos, location.end_pos, 1042 ReportMessageAt(location.beg_pos, location.end_pos,
1003 "strict_reserved_word", NULL); 1043 "strict_reserved_word", NULL);
1004 *ok = false; 1044 *ok = false;
1005 return Expression::Default(); 1045 return Expression::Default();
1006 } 1046 }
1007 // FALLTHROUGH 1047 // FALLTHROUGH
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 } 1366 }
1327 1367
1328 1368
1329 PreParser::Identifier PreParser::GetIdentifierSymbol() { 1369 PreParser::Identifier PreParser::GetIdentifierSymbol() {
1330 LogSymbol(); 1370 LogSymbol();
1331 if (scanner_->current_token() == i::Token::FUTURE_RESERVED_WORD) { 1371 if (scanner_->current_token() == i::Token::FUTURE_RESERVED_WORD) {
1332 return Identifier::FutureReserved(); 1372 return Identifier::FutureReserved();
1333 } else if (scanner_->current_token() == 1373 } else if (scanner_->current_token() ==
1334 i::Token::FUTURE_STRICT_RESERVED_WORD) { 1374 i::Token::FUTURE_STRICT_RESERVED_WORD) {
1335 return Identifier::FutureStrictReserved(); 1375 return Identifier::FutureStrictReserved();
1376 } else if (scanner_->current_token() == i::Token::LET) {
1377 return Identifier::FutureStrictReserved();
1336 } 1378 }
1337 if (scanner_->is_literal_ascii()) { 1379 if (scanner_->is_literal_ascii()) {
1338 // Detect strict-mode poison words. 1380 // Detect strict-mode poison words.
1339 if (scanner_->literal_length() == 4 && 1381 if (scanner_->literal_length() == 4 &&
1340 !strncmp(scanner_->literal_ascii_string().start(), "eval", 4)) { 1382 !strncmp(scanner_->literal_ascii_string().start(), "eval", 4)) {
1341 return Identifier::Eval(); 1383 return Identifier::Eval();
1342 } 1384 }
1343 if (scanner_->literal_length() == 9 && 1385 if (scanner_->literal_length() == 9 &&
1344 !strncmp(scanner_->literal_ascii_string().start(), "arguments", 9)) { 1386 !strncmp(scanner_->literal_ascii_string().start(), "arguments", 9)) {
1345 return Identifier::Arguments(); 1387 return Identifier::Arguments();
1346 } 1388 }
1347 } 1389 }
1348 return Identifier::Default(); 1390 return Identifier::Default();
1349 } 1391 }
1350 1392
1351 1393
1352 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { 1394 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) {
1353 i::Token::Value next = Next(); 1395 i::Token::Value next = Next();
1354 switch (next) { 1396 switch (next) {
1355 case i::Token::FUTURE_RESERVED_WORD: { 1397 case i::Token::FUTURE_RESERVED_WORD: {
1356 i::Scanner::Location location = scanner_->location(); 1398 i::Scanner::Location location = scanner_->location();
1357 ReportMessageAt(location.beg_pos, location.end_pos, 1399 ReportMessageAt(location.beg_pos, location.end_pos,
1358 "reserved_word", NULL); 1400 "reserved_word", NULL);
1359 *ok = false; 1401 *ok = false;
1402 return GetIdentifierSymbol();
1360 } 1403 }
1404 case i::Token::LET:
1405 if (i::FLAG_harmony_block_scoping) {
1406 *ok = false;
1407 return Identifier::Default();
1408 }
1361 // FALLTHROUGH 1409 // FALLTHROUGH
1362 case i::Token::FUTURE_STRICT_RESERVED_WORD: 1410 case i::Token::FUTURE_STRICT_RESERVED_WORD:
1363 case i::Token::IDENTIFIER: 1411 case i::Token::IDENTIFIER:
1364 return GetIdentifierSymbol(); 1412 return GetIdentifierSymbol();
1365 default: 1413 default:
1366 *ok = false; 1414 *ok = false;
1367 return Identifier::Default(); 1415 return Identifier::Default();
1368 } 1416 }
1369 } 1417 }
1370 1418
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 i::Token::Value next = Next(); 1471 i::Token::Value next = Next();
1424 if (i::Token::IsKeyword(next)) { 1472 if (i::Token::IsKeyword(next)) {
1425 int pos = scanner_->location().beg_pos; 1473 int pos = scanner_->location().beg_pos;
1426 const char* keyword = i::Token::String(next); 1474 const char* keyword = i::Token::String(next);
1427 log_->LogAsciiSymbol(pos, i::Vector<const char>(keyword, 1475 log_->LogAsciiSymbol(pos, i::Vector<const char>(keyword,
1428 i::StrLength(keyword))); 1476 i::StrLength(keyword)));
1429 return Identifier::Default(); 1477 return Identifier::Default();
1430 } 1478 }
1431 if (next == i::Token::IDENTIFIER || 1479 if (next == i::Token::IDENTIFIER ||
1432 next == i::Token::FUTURE_RESERVED_WORD || 1480 next == i::Token::FUTURE_RESERVED_WORD ||
1433 next == i::Token::FUTURE_STRICT_RESERVED_WORD) { 1481 next == i::Token::FUTURE_STRICT_RESERVED_WORD ||
1482 next == i::Token::LET) {
1434 return GetIdentifierSymbol(); 1483 return GetIdentifierSymbol();
1435 } 1484 }
1436 *ok = false; 1485 *ok = false;
1437 return Identifier::Default(); 1486 return Identifier::Default();
1438 } 1487 }
1439 1488
1440 #undef CHECK_OK 1489 #undef CHECK_OK
1441 1490
1442 1491
1443 // This function reads an identifier and determines whether or not it 1492 // This function reads an identifier and determines whether or not it
1444 // is 'get' or 'set'. 1493 // is 'get' or 'set'.
1445 PreParser::Identifier PreParser::ParseIdentifierNameOrGetOrSet(bool* is_get, 1494 PreParser::Identifier PreParser::ParseIdentifierNameOrGetOrSet(bool* is_get,
1446 bool* is_set, 1495 bool* is_set,
1447 bool* ok) { 1496 bool* ok) {
1448 Identifier result = ParseIdentifierName(ok); 1497 Identifier result = ParseIdentifierName(ok);
1449 if (!*ok) return Identifier::Default(); 1498 if (!*ok) return Identifier::Default();
1450 if (scanner_->is_literal_ascii() && 1499 if (scanner_->is_literal_ascii() &&
1451 scanner_->literal_length() == 3) { 1500 scanner_->literal_length() == 3) {
1452 const char* token = scanner_->literal_ascii_string().start(); 1501 const char* token = scanner_->literal_ascii_string().start();
1453 *is_get = strncmp(token, "get", 3) == 0; 1502 *is_get = strncmp(token, "get", 3) == 0;
1454 *is_set = !*is_get && strncmp(token, "set", 3) == 0; 1503 *is_set = !*is_get && strncmp(token, "set", 3) == 0;
1455 } 1504 }
1456 return result; 1505 return result;
1457 } 1506 }
1458 1507
1459 bool PreParser::peek_any_identifier() { 1508 bool PreParser::peek_any_identifier() {
1460 i::Token::Value next = peek(); 1509 i::Token::Value next = peek();
1461 return next == i::Token::IDENTIFIER || 1510 return next == i::Token::IDENTIFIER ||
1462 next == i::Token::FUTURE_RESERVED_WORD || 1511 next == i::Token::FUTURE_RESERVED_WORD ||
1463 next == i::Token::FUTURE_STRICT_RESERVED_WORD; 1512 next == i::Token::FUTURE_STRICT_RESERVED_WORD ||
1513 next == i::Token::LET;
1464 } 1514 }
1465 } } // v8::preparser 1515 } } // v8::preparser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698