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

Side by Side Diff: src/preparser.cc

Issue 7061008: Create template system for strict-mode tests. (Closed)
Patch Set: Remove debug print. Created 9 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
« no previous file with comments | « preparser/preparser-process.cc ('k') | test/preparser/preparser.expectation » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // of 'for-in' loops. 302 // of 'for-in' loops.
303 PreParser::Statement PreParser::ParseVariableDeclarations(bool accept_IN, 303 PreParser::Statement PreParser::ParseVariableDeclarations(bool accept_IN,
304 int* num_decl, 304 int* num_decl,
305 bool* ok) { 305 bool* ok) {
306 // VariableDeclarations :: 306 // VariableDeclarations ::
307 // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[','] 307 // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[',']
308 308
309 if (peek() == i::Token::VAR) { 309 if (peek() == i::Token::VAR) {
310 Consume(i::Token::VAR); 310 Consume(i::Token::VAR);
311 } else if (peek() == i::Token::CONST) { 311 } else if (peek() == i::Token::CONST) {
312 if (strict_mode()) {
313 i::Scanner::Location location = scanner_->peek_location();
314 ReportMessageAt(location.beg_pos, location.end_pos,
315 "strict_const", NULL);
316 *ok = false;
317 return Statement::Default();
318 }
312 Consume(i::Token::CONST); 319 Consume(i::Token::CONST);
313 } else { 320 } else {
314 *ok = false; 321 *ok = false;
315 return Statement::Default(); 322 return Statement::Default();
316 } 323 }
317 324
318 // The scope of a variable/const declared anywhere inside a function 325 // The scope of a variable/const declared anywhere inside a function
319 // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). . 326 // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). .
320 int nvars = 0; // the number of variables declared 327 int nvars = 0; // the number of variables declared
321 do { 328 do {
(...skipping 19 matching lines...) Expand all
341 } 348 }
342 349
343 350
344 PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) { 351 PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) {
345 // ExpressionStatement | LabelledStatement :: 352 // ExpressionStatement | LabelledStatement ::
346 // Expression ';' 353 // Expression ';'
347 // Identifier ':' Statement 354 // Identifier ':' Statement
348 355
349 Expression expr = ParseExpression(true, CHECK_OK); 356 Expression expr = ParseExpression(true, CHECK_OK);
350 if (peek() == i::Token::COLON && expr.IsRawIdentifier()) { 357 if (peek() == i::Token::COLON && expr.IsRawIdentifier()) {
351 Consume(i::Token::COLON); 358 if (!strict_mode() || !expr.AsIdentifier().IsFutureReserved()) {
352 ParseStatement(ok); 359 Consume(i::Token::COLON);
353 return Statement::Default(); 360 ParseStatement(ok);
361 return Statement::Default();
362 }
354 } 363 }
355 // Parsed expression statement. 364 // Parsed expression statement.
356 ExpectSemicolon(CHECK_OK); 365 ExpectSemicolon(CHECK_OK);
357 return Statement::ExpressionStatement(expr); 366 return Statement::ExpressionStatement(expr);
358 } 367 }
359 368
360 369
361 PreParser::Statement PreParser::ParseIfStatement(bool* ok) { 370 PreParser::Statement PreParser::ParseIfStatement(bool* ok) {
362 // IfStatement :: 371 // IfStatement ::
363 // 'if' '(' Expression ')' Statement ('else' Statement)? 372 // 'if' '(' Expression ')' Statement ('else' Statement)?
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 } 1418 }
1410 return result; 1419 return result;
1411 } 1420 }
1412 1421
1413 bool PreParser::peek_any_identifier() { 1422 bool PreParser::peek_any_identifier() {
1414 i::Token::Value next = peek(); 1423 i::Token::Value next = peek();
1415 return next == i::Token::IDENTIFIER || 1424 return next == i::Token::IDENTIFIER ||
1416 next == i::Token::FUTURE_RESERVED_WORD; 1425 next == i::Token::FUTURE_RESERVED_WORD;
1417 } 1426 }
1418 } } // v8::preparser 1427 } } // v8::preparser
OLDNEW
« no previous file with comments | « preparser/preparser-process.cc ('k') | test/preparser/preparser.expectation » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698