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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/recover.dart

Issue 2778213002: Use message.yaml in parser. (Closed)
Patch Set: Update subpackage relationships. 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/scanner/recover.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/recover.dart b/pkg/front_end/lib/src/fasta/scanner/recover.dart
index 44763f85a5786eed922354cd88b1c44f3c023e7f..33e79baf232d1edd66dc629f90494aa3b100da60 100644
--- a/pkg/front_end/lib/src/fasta/scanner/recover.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/recover.dart
@@ -4,9 +4,23 @@
library fasta.scanner.recover;
+import '../fasta_codes.dart'
+ show
+ FastaCode,
+ codeAsciiControlCharacter,
+ codeEncoding,
+ codeExpectedHexDigit,
+ codeMissingExponent,
+ codeNonAsciiIdentifier,
+ codeNonAsciiWhitespace,
+ codeUnexpectedDollarInString,
+ codeUnmatchedToken,
+ codeUnterminatedComment,
+ codeUnterminatedString;
+
import 'token.dart' show StringToken, SymbolToken, Token;
-import 'error_token.dart' show NonAsciiIdentifierToken, ErrorKind, ErrorToken;
+import 'error_token.dart' show NonAsciiIdentifierToken, ErrorToken;
import 'precedence.dart' as Precedence;
@@ -161,52 +175,34 @@ Token defaultRecoveryStrategy(
next = next.next;
} while (next is ErrorToken && first.errorCode == next.errorCode);
- switch (first.errorCode) {
- case ErrorKind.Encoding:
- case ErrorKind.NonAsciiWhitespace:
- case ErrorKind.AsciiControlCharacter:
- treatAsWhitespace = true;
- break;
-
- case ErrorKind.NonAsciiIdentifier:
- current = recoverIdentifier(first);
- assert(current.next != null);
- break;
-
- case ErrorKind.MissingExponent:
- current = recoverExponent();
- assert(current.next != null);
- break;
-
- case ErrorKind.UnterminatedString:
- current = recoverString();
- assert(current.next != null);
- break;
-
- case ErrorKind.ExpectedHexDigit:
- current = recoverHexDigit();
- assert(current.next != null);
- break;
-
- case ErrorKind.UnexpectedDollarInString:
- current = recoverStringInterpolation();
- assert(current.next != null);
- break;
-
- case ErrorKind.UnterminatedComment:
- current = recoverComment();
- assert(current.next != null);
- break;
-
- case ErrorKind.UnmatchedToken:
- current = recoverUnmatched();
- assert(current.next != null);
- break;
-
- case ErrorKind.UnterminatedToken: // TODO(ahe): Can this happen?
- default:
- treatAsWhitespace = true;
- break;
+ FastaCode code = first.errorCode;
+ if (code == codeEncoding ||
+ code == codeNonAsciiWhitespace ||
+ code == codeAsciiControlCharacter) {
+ treatAsWhitespace = true;
+ } else if (code == codeNonAsciiIdentifier) {
+ current = recoverIdentifier(first);
+ assert(current.next != null);
+ } else if (code == codeMissingExponent) {
+ current = recoverExponent();
+ assert(current.next != null);
+ } else if (code == codeUnterminatedString) {
+ current = recoverString();
+ assert(current.next != null);
+ } else if (code == codeExpectedHexDigit) {
+ current = recoverHexDigit();
+ assert(current.next != null);
+ } else if (code == codeUnexpectedDollarInString) {
+ current = recoverStringInterpolation();
+ assert(current.next != null);
+ } else if (code == codeUnterminatedComment) {
+ current = recoverComment();
+ assert(current.next != null);
+ } else if (code == codeUnmatchedToken) {
+ current = recoverUnmatched();
+ assert(current.next != null);
+ } else {
+ treatAsWhitespace = true;
}
if (treatAsWhitespace) continue;
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/error_token.dart ('k') | pkg/front_end/lib/src/fasta/source/diet_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698