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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/scanner/parser.dart

Issue 282453004: Dart2js enum parsing. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Typo Created 6 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 | Annotate | Revision Log
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 part of scanner; 5 part of scanner;
6 6
7 class FormalParameterType { 7 class FormalParameterType {
8 final String type; 8 final String type;
9 const FormalParameterType(this.type); 9 const FormalParameterType(this.type);
10 bool get isRequired => this == REQUIRED; 10 bool get isRequired => this == REQUIRED;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 listener.endCompilationUnit(count, token); 55 listener.endCompilationUnit(count, token);
56 return token; 56 return token;
57 } 57 }
58 58
59 Token parseTopLevelDeclaration(Token token) { 59 Token parseTopLevelDeclaration(Token token) {
60 token = parseMetadataStar(token); 60 token = parseMetadataStar(token);
61 final String value = token.stringValue; 61 final String value = token.stringValue;
62 if ((identical(value, 'abstract') && optional('class', token.next)) 62 if ((identical(value, 'abstract') && optional('class', token.next))
63 || identical(value, 'class')) { 63 || identical(value, 'class')) {
64 return parseClassOrNamedMixinApplication(token); 64 return parseClassOrNamedMixinApplication(token);
65 } else if (identical(value, 'enum')) {
66 return parseEnum(token);
65 } else if (identical(value, 'typedef')) { 67 } else if (identical(value, 'typedef')) {
66 return parseTypedef(token); 68 return parseTypedef(token);
67 } else if (identical(value, 'library')) { 69 } else if (identical(value, 'library')) {
68 return parseLibraryName(token); 70 return parseLibraryName(token);
69 } else if (identical(value, 'import')) { 71 } else if (identical(value, 'import')) {
70 return parseImport(token); 72 return parseImport(token);
71 } else if (identical(value, 'export')) { 73 } else if (identical(value, 'export')) {
72 return parseExport(token); 74 return parseExport(token);
73 } else if (identical(value, 'part')) { 75 } else if (identical(value, 'part')) {
74 return parsePartOrPartOf(token); 76 return parsePartOrPartOf(token);
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 BeginGroupToken beginGroupToken = token; 449 BeginGroupToken beginGroupToken = token;
448 Token endGroup = beginGroupToken.endGroup; 450 Token endGroup = beginGroupToken.endGroup;
449 if (endGroup == null) { 451 if (endGroup == null) {
450 return listener.unmatched(beginGroupToken); 452 return listener.unmatched(beginGroupToken);
451 } else if (!identical(endGroup.kind, $CLOSE_CURLY_BRACKET)) { 453 } else if (!identical(endGroup.kind, $CLOSE_CURLY_BRACKET)) {
452 return listener.unmatched(beginGroupToken); 454 return listener.unmatched(beginGroupToken);
453 } 455 }
454 return beginGroupToken.endGroup; 456 return beginGroupToken.endGroup;
455 } 457 }
456 458
459 Token parseEnum(Token token) {
ahe 2014/05/12 11:24:03 This looks reasonable. I think this fails to pars
460 listener.beginEnum(token);
461 Token enumKeyword = token;
462 token = parseIdentifier(token.next);
463 token = expect('{', token);
464 int count = 0;
465 if (!optional('}', token)) {
466 token = parseIdentifier(token);
467 count++;
468 while (!optional('}', token)) {
469 token = expect(',', token);
470 token = parseIdentifier(token);
471 count++;
472 }
473 }
474 Token endBrace = token;
475 listener.endEnum(enumKeyword, endBrace, count);
476 return token.next;
477 }
478
457 Token parseClassOrNamedMixinApplication(Token token) { 479 Token parseClassOrNamedMixinApplication(Token token) {
458 Token begin = token; 480 Token begin = token;
459 Token abstractKeyword; 481 Token abstractKeyword;
460 if (optional('abstract', token)) { 482 if (optional('abstract', token)) {
461 abstractKeyword = token; 483 abstractKeyword = token;
462 token = token.next; 484 token = token.next;
463 } 485 }
464 Token classKeyword = token; 486 Token classKeyword = token;
465 var isMixinApplication = optional('=', peekAfterType(token.next)); 487 var isMixinApplication = optional('=', peekAfterType(token.next));
466 if (isMixinApplication) { 488 if (isMixinApplication) {
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 } 2467 }
2446 listener.handleContinueStatement(hasTarget, continueKeyword, token); 2468 listener.handleContinueStatement(hasTarget, continueKeyword, token);
2447 return expectSemicolon(token); 2469 return expectSemicolon(token);
2448 } 2470 }
2449 2471
2450 Token parseEmptyStatement(Token token) { 2472 Token parseEmptyStatement(Token token) {
2451 listener.handleEmptyStatement(token); 2473 listener.handleEmptyStatement(token);
2452 return expectSemicolon(token); 2474 return expectSemicolon(token);
2453 } 2475 }
2454 } 2476 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698