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

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

Issue 9370029: Better parsing of interfaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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
« no previous file with comments | « dart/frog/leg/scanner/class_element_parser.dart ('k') | dart/tests/co19/co19-leg.status » ('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 { 9 class Parser {
10 final Listener listener; 10 final Listener listener;
11 bool mayParseFunctionExpressions = true; 11 bool mayParseFunctionExpressions = true;
12 12
13 Parser(Listener this.listener); 13 Parser(Listener this.listener);
14 14
15 void parseUnit(Token token) { 15 void parseUnit(Token token) {
16 while (token.kind !== EOF_TOKEN) { 16 while (token.kind !== EOF_TOKEN) {
17 final String value = token.stringValue; 17 token = parseTopLevelDeclaration(token);
18 if (value === 'interface') {
19 token = parseInterface(token);
20 } else if ((value === 'abstract') || (value === 'class')) {
21 token = parseClass(token);
22 } else if (value === 'typedef') {
23 token = parseNamedFunctionAlias(token);
24 } else if (value === '#') {
25 token = parseScriptTags(token);
26 } else {
27 token = parseTopLevelMember(token);
28 }
29 } 18 }
30 } 19 }
31 20
21 Token parseTopLevelDeclaration(Token token) {
22 final String value = token.stringValue;
23 if (value === 'interface') {
24 return parseInterface(token);
25 } else if ((value === 'abstract') || (value === 'class')) {
26 return parseClass(token);
27 } else if (value === 'typedef') {
28 return parseNamedFunctionAlias(token);
29 } else if (value === '#') {
30 return parseScriptTags(token);
31 } else {
32 return parseTopLevelMember(token);
33 }
34 }
35
32 Token parseInterface(Token token) { 36 Token parseInterface(Token token) {
33 Token interfaceKeyword = token; 37 Token interfaceKeyword = token;
34 listener.beginInterface(token); 38 listener.beginInterface(token);
35 token = parseIdentifier(token.next); 39 token = parseIdentifier(token.next);
36 token = parseTypeVariablesOpt(token); 40 token = parseTypeVariablesOpt(token);
37 int supertypeCount = 0; 41 int supertypeCount = 0;
38 Token extendsKeyword = null; 42 Token extendsKeyword = null;
39 if (optional('extends', token)) { 43 if (optional('extends', token)) {
40 extendsKeyword = token; 44 extendsKeyword = token;
41 do { 45 do {
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 } 1624 }
1621 listener.handleContinueStatement(hasTarget, continueKeyword, token); 1625 listener.handleContinueStatement(hasTarget, continueKeyword, token);
1622 return expectSemicolon(token); 1626 return expectSemicolon(token);
1623 } 1627 }
1624 1628
1625 Token parseEmptyStatement(Token token) { 1629 Token parseEmptyStatement(Token token) {
1626 listener.handleEmptyStatement(token); 1630 listener.handleEmptyStatement(token);
1627 return expectSemicolon(token); 1631 return expectSemicolon(token);
1628 } 1632 }
1629 } 1633 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/class_element_parser.dart ('k') | dart/tests/co19/co19-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698