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

Side by Side Diff: dart/frog/leg/scanner/parser.dart

Issue 8497042: Allow error-recovery in top-level nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased, address review comments, and frogsh Created 9 years, 1 month 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
« no previous file with comments | « dart/frog/leg/scanner/node_scanner_bench.dart ('k') | dart/frog/leg/scanner/scanner_bench.dart » ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * An event generating parser of Dart programs. This parser expects 6 * An event generating parser of Dart programs. This parser expects
7 * all tokens in a linked list. 7 * all tokens in a linked list.
8 */ 8 */
9 class Parser<L extends Listener> { 9 class Parser<L extends Listener> {
10 final L listener; 10 final L listener;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 case kind === EQ_TOKEN: 298 case kind === EQ_TOKEN:
299 break LOOP; 299 break LOOP;
300 default: 300 default:
301 previous = token; 301 previous = token;
302 token = next(token); 302 token = next(token);
303 break; 303 break;
304 } 304 }
305 } 305 }
306 token = parseIdentifier(previous); 306 token = parseIdentifier(previous);
307 bool isField; 307 bool isField;
308 if (optional('(', token)) { 308 while (true) {
309 isField = false; 309 // Loop to allow the listener to rewrite the token stream to
310 } else if (optional('=', token) || optional(';', token)) { 310 // make the parser happy.
311 isField = true; 311 if (optional('(', token)) {
312 } else { 312 isField = false;
313 token = listener.unexpected(token); 313 break;
314 } else if (optional('=', token) || optional(';', token)) {
315 isField = true;
316 break;
317 } else {
318 token = listener.unexpected(token);
319 }
314 } 320 }
315 while (token !== null && 321 while (token !== null &&
316 token.kind !== LBRACE_TOKEN && 322 token.kind !== LBRACE_TOKEN &&
317 token.kind !== SEMICOLON_TOKEN) { 323 token.kind !== SEMICOLON_TOKEN) {
318 token = next(token); 324 token = next(token);
319 } 325 }
320 if (!optional(';', token)) { 326 if (!optional(';', token)) {
321 token = skipBlock(token); 327 token = skipBlock(token);
322 } 328 }
323 if (isField) { 329 if (isField) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 if (optional(';', token)) { 705 if (optional(';', token)) {
700 listener.endRethrowStatement(throwToken, token); 706 listener.endRethrowStatement(throwToken, token);
701 return token.next; 707 return token.next;
702 } else { 708 } else {
703 token = parseExpression(token); 709 token = parseExpression(token);
704 listener.endThrowStatement(throwToken, token); 710 listener.endThrowStatement(throwToken, token);
705 return expectSemicolon(token); 711 return expectSemicolon(token);
706 } 712 }
707 } 713 }
708 } 714 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/node_scanner_bench.dart ('k') | dart/frog/leg/scanner/scanner_bench.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698