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

Side by Side Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2725973004: Correctly recover from incorrect imports, etc. (Closed)
Patch Set: Created 3 years, 9 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.parser.parser; 5 library fasta.parser.parser;
6 6
7 import '../scanner.dart' show ErrorToken; 7 import '../scanner.dart' show ErrorToken;
8 8
9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; 9 import '../scanner/recover.dart' show closeBraceFor, skipToEof;
10 10
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 mayParseFunctionExpressions = old; 1447 mayParseFunctionExpressions = old;
1448 listener.endInitializers(count, begin, token); 1448 listener.endInitializers(count, begin, token);
1449 return token; 1449 return token;
1450 } 1450 }
1451 1451
1452 Token parseLiteralStringOrRecoverExpression(Token token) { 1452 Token parseLiteralStringOrRecoverExpression(Token token) {
1453 if (identical(token.kind, STRING_TOKEN)) { 1453 if (identical(token.kind, STRING_TOKEN)) {
1454 return parseLiteralString(token); 1454 return parseLiteralString(token);
1455 } else { 1455 } else {
1456 reportRecoverableError(token, ErrorKind.ExpectedString); 1456 reportRecoverableError(token, ErrorKind.ExpectedString);
1457 return parseExpression(token); 1457 return parseRecoverExpression(token);
1458 } 1458 }
1459 } 1459 }
1460 1460
1461 Token expectSemicolon(Token token) { 1461 Token expectSemicolon(Token token) {
1462 return expect(';', token); 1462 return expect(';', token);
1463 } 1463 }
1464 1464
1465 bool isModifier(Token token) { 1465 bool isModifier(Token token) {
1466 final String value = token.stringValue; 1466 final String value = token.stringValue;
1467 return (identical('final', value)) || 1467 return (identical('final', value)) ||
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 BeginGroupToken begin = token; 2416 BeginGroupToken begin = token;
2417 token = (begin.endGroup != null) ? begin.endGroup : token; 2417 token = (begin.endGroup != null) ? begin.endGroup : token;
2418 } else if (token is ErrorToken) { 2418 } else if (token is ErrorToken) {
2419 reportErrorToken(token, false); 2419 reportErrorToken(token, false);
2420 } 2420 }
2421 token = token.next; 2421 token = token.next;
2422 } 2422 }
2423 return token; 2423 return token;
2424 } 2424 }
2425 2425
2426 Token parseRecoverExpression(Token token) => parseExpression(token);
2427
2426 int expressionDepth = 0; 2428 int expressionDepth = 0;
2427 Token parseExpression(Token token) { 2429 Token parseExpression(Token token) {
2428 if (expressionDepth++ > 500) { 2430 if (expressionDepth++ > 500) {
2429 // This happens in degenerate programs, for example, with a lot of nested 2431 // This happens in degenerate programs, for example, with a lot of nested
2430 // list literals. This is provoked by, for examaple, the language test 2432 // list literals. This is provoked by, for examaple, the language test
2431 // deep_nesting1_negative_test. 2433 // deep_nesting1_negative_test.
2432 return reportUnrecoverableError(token, ErrorKind.StackOverflow); 2434 return reportUnrecoverableError(token, ErrorKind.StackOverflow);
2433 } 2435 }
2434 listener.beginExpression(token); 2436 listener.beginExpression(token);
2435 Token result = optional('throw', token) 2437 Token result = optional('throw', token)
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 break; 3559 break;
3558 } 3560 }
3559 if (isRecoverable) { 3561 if (isRecoverable) {
3560 listener.handleRecoverableError(token, kind, arguments); 3562 listener.handleRecoverableError(token, kind, arguments);
3561 return null; 3563 return null;
3562 } else { 3564 } else {
3563 return listener.handleUnrecoverableError(token, kind, arguments); 3565 return listener.handleUnrecoverableError(token, kind, arguments);
3564 } 3566 }
3565 } 3567 }
3566 } 3568 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/listener.dart ('k') | pkg/front_end/lib/src/fasta/source/outline_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698