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

Unified Diff: dart/pkg/compiler/lib/src/scanner/class_element_parser.dart

Issue 808953004: Recover from fatal parser errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42860. Created 5 years, 11 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
« no previous file with comments | « dart/pkg/compiler/lib/src/resolution/members.dart ('k') | dart/pkg/compiler/lib/src/scanner/listener.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/compiler/lib/src/scanner/class_element_parser.dart
diff --git a/dart/pkg/compiler/lib/src/scanner/class_element_parser.dart b/dart/pkg/compiler/lib/src/scanner/class_element_parser.dart
index f0b0020ec86cc06886c810037a861e714acf8d4c..ccd251da832e2850917e9af4280d2c75ae826014 100644
--- a/dart/pkg/compiler/lib/src/scanner/class_element_parser.dart
+++ b/dart/pkg/compiler/lib/src/scanner/class_element_parser.dart
@@ -49,11 +49,30 @@ class PartialClassElement extends ClassElementX with PartialElement {
compiler.parser.measure(() {
MemberListener listener = new MemberListener(compiler, this);
Parser parser = new ClassElementParser(listener);
- Token token = parser.parseTopLevelDeclaration(beginToken);
- assert(identical(token, endToken.next));
- cachedNode = listener.popNode();
- assert(invariant(beginToken, listener.nodes.isEmpty,
- message: "Non-empty listener stack: ${listener.nodes}"));
+ try {
+ Token token = parser.parseTopLevelDeclaration(beginToken);
+ assert(identical(token, endToken.next));
+ cachedNode = listener.popNode();
+ assert(
+ invariant(
+ beginToken, listener.nodes.isEmpty,
+ message: "Non-empty listener stack: ${listener.nodes}"));
+ } on ParserError catch (e) {
+ // TODO(ahe): Often, a ParserError is thrown while parsing the class
+ // body. This means that the stack actually contains most of the
+ // information synthesized below. Consider rewriting the parser so
+ // endClassDeclaration is called before parsing the class body.
+ Identifier name = new Identifier(findMyName(beginToken));
+ NodeList typeParameters = null;
+ Node supertype = null;
+ NodeList interfaces = listener.makeNodeList(0, null, null, ",");
+ Token extendsKeyword = null;
+ NodeList body = listener.makeNodeList(0, beginToken, endToken, null);
+ cachedNode = new ClassNode(
+ Modifiers.EMPTY, name, typeParameters, supertype, interfaces,
+ beginToken, extendsKeyword, body, endToken);
+ hasParseError = true;
+ }
});
compiler.patchParser.measure(() {
if (isPatched) {
« no previous file with comments | « dart/pkg/compiler/lib/src/resolution/members.dart ('k') | dart/pkg/compiler/lib/src/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698