| OLD | NEW | 
|---|
| 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 /** | 7 /** | 
| 8  * An event generating parser of Dart programs. This parser expects | 8  * An event generating parser of Dart programs. This parser expects | 
| 9  * all tokens in a linked list (aka a token stream). | 9  * all tokens in a linked list (aka a token stream). | 
| 10  * | 10  * | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 41       listener.endTopLevelDeclaration(token); | 41       listener.endTopLevelDeclaration(token); | 
| 42       count++; | 42       count++; | 
| 43     } | 43     } | 
| 44     listener.endCompilationUnit(count, token); | 44     listener.endCompilationUnit(count, token); | 
| 45     return token; | 45     return token; | 
| 46   } | 46   } | 
| 47 | 47 | 
| 48   Token parseTopLevelDeclaration(Token token) { | 48   Token parseTopLevelDeclaration(Token token) { | 
| 49     token = parseMetadataStar(token); | 49     token = parseMetadataStar(token); | 
| 50     final String value = token.stringValue; | 50     final String value = token.stringValue; | 
| 51     if (identical(value, 'interface')) { | 51     if ((identical(value, 'abstract')) || (identical(value, 'class'))) { | 
| 52       return parseInterface(token); |  | 
| 53     } else if ((identical(value, 'abstract')) || (identical(value, 'class'))) { |  | 
| 54       return parseClass(token); | 52       return parseClass(token); | 
| 55     } else if (identical(value, 'typedef')) { | 53     } else if (identical(value, 'typedef')) { | 
| 56       return parseTypedef(token); | 54       return parseTypedef(token); | 
| 57     } else if (identical(value, '#')) { | 55     } else if (identical(value, '#')) { | 
| 58       return parseScriptTags(token); | 56       return parseScriptTags(token); | 
| 59     } else if (identical(value, 'library')) { | 57     } else if (identical(value, 'library')) { | 
| 60       return parseLibraryName(token); | 58       return parseLibraryName(token); | 
| 61     } else if (identical(value, 'import')) { | 59     } else if (identical(value, 'import')) { | 
| 62       return parseImport(token); | 60       return parseImport(token); | 
| 63     } else if (identical(value, 'export')) { | 61     } else if (identical(value, 'export')) { | 
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 228     Token period = null; | 226     Token period = null; | 
| 229     if (optional('.', token)) { | 227     if (optional('.', token)) { | 
| 230       period = token; | 228       period = token; | 
| 231       token = parseIdentifier(token.next); | 229       token = parseIdentifier(token.next); | 
| 232     } | 230     } | 
| 233     token = parseArgumentsOpt(token); | 231     token = parseArgumentsOpt(token); | 
| 234     listener.endMetadata(atToken, period, token); | 232     listener.endMetadata(atToken, period, token); | 
| 235     return token; | 233     return token; | 
| 236   } | 234   } | 
| 237 | 235 | 
| 238   Token parseInterface(Token token) { |  | 
| 239     Token interfaceKeyword = token; |  | 
| 240     listener.beginInterface(token); |  | 
| 241     token = parseIdentifier(token.next); |  | 
| 242     token = parseTypeVariablesOpt(token); |  | 
| 243     int supertypeCount = 0; |  | 
| 244     Token extendsKeyword = null; |  | 
| 245     if (optional('extends', token)) { |  | 
| 246       extendsKeyword = token; |  | 
| 247       do { |  | 
| 248         token = parseType(token.next); |  | 
| 249         ++supertypeCount; |  | 
| 250       } while (optional(',', token)); |  | 
| 251     } |  | 
| 252     token = parseDefaultClauseOpt(token); |  | 
| 253     token = parseInterfaceBody(token); |  | 
| 254     listener.endInterface(supertypeCount, interfaceKeyword, |  | 
| 255                           extendsKeyword, token); |  | 
| 256     return token.next; |  | 
| 257   } |  | 
| 258 |  | 
| 259   Token parseInterfaceBody(Token token) { |  | 
| 260     return parseClassBody(token); |  | 
| 261   } |  | 
| 262 |  | 
| 263   Token parseTypedef(Token token) { | 236   Token parseTypedef(Token token) { | 
| 264     Token typedefKeyword = token; | 237     Token typedefKeyword = token; | 
| 265     if (optional('=', peekAfterType(token.next))) { | 238     if (optional('=', peekAfterType(token.next))) { | 
| 266       listener.beginNamedMixinApplication(token); | 239       listener.beginNamedMixinApplication(token); | 
| 267       token = parseIdentifier(token.next); | 240       token = parseIdentifier(token.next); | 
| 268       token = parseTypeVariablesOpt(token); | 241       token = parseTypeVariablesOpt(token); | 
| 269       token = expect('=', token); | 242       token = expect('=', token); | 
| 270       token = parseModifiers(token); | 243       token = parseModifiers(token); | 
| 271       token = parseMixinApplication(token); | 244       token = parseMixinApplication(token); | 
| 272       Token implementsKeyword = null; | 245       Token implementsKeyword = null; | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 404     if (identical(kind, KEYWORD_TOKEN)) { | 377     if (identical(kind, KEYWORD_TOKEN)) { | 
| 405       Keyword keyword = token.value; | 378       Keyword keyword = token.value; | 
| 406       String value = keyword.stringValue; | 379       String value = keyword.stringValue; | 
| 407       return keyword.isPseudo | 380       return keyword.isPseudo | 
| 408           || (identical(value, 'dynamic')) | 381           || (identical(value, 'dynamic')) | 
| 409           || (identical(value, 'void')); | 382           || (identical(value, 'void')); | 
| 410     } | 383     } | 
| 411     return false; | 384     return false; | 
| 412   } | 385   } | 
| 413 | 386 | 
| 414   Token parseDefaultClauseOpt(Token token) { |  | 
| 415     if (isDefaultKeyword(token)) { |  | 
| 416       // TODO(ahe): Remove support for 'factory' in this position. |  | 
| 417       Token defaultKeyword = token; |  | 
| 418       listener.beginDefaultClause(defaultKeyword); |  | 
| 419       token = parseIdentifier(token.next); |  | 
| 420       token = parseQualifiedRestOpt(token); |  | 
| 421       token = parseTypeVariablesOpt(token); |  | 
| 422       listener.endDefaultClause(defaultKeyword); |  | 
| 423     } else { |  | 
| 424       listener.handleNoDefaultClause(token); |  | 
| 425     } |  | 
| 426     return token; |  | 
| 427   } |  | 
| 428 |  | 
| 429   Token parseQualified(Token token) { | 387   Token parseQualified(Token token) { | 
| 430     token = parseIdentifier(token); | 388     token = parseIdentifier(token); | 
| 431     while (optional('.', token)) { | 389     while (optional('.', token)) { | 
| 432       token = parseQualifiedRest(token); | 390       token = parseQualifiedRest(token); | 
| 433     } | 391     } | 
| 434     return token; | 392     return token; | 
| 435   } | 393   } | 
| 436 | 394 | 
| 437   Token parseQualifiedRestOpt(Token token) { | 395   Token parseQualifiedRestOpt(Token token) { | 
| 438     if (optional('.', token)) { | 396     if (optional('.', token)) { | 
| (...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2237     } | 2195     } | 
| 2238     listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2196     listener.handleContinueStatement(hasTarget, continueKeyword, token); | 
| 2239     return expectSemicolon(token); | 2197     return expectSemicolon(token); | 
| 2240   } | 2198   } | 
| 2241 | 2199 | 
| 2242   Token parseEmptyStatement(Token token) { | 2200   Token parseEmptyStatement(Token token) { | 
| 2243     listener.handleEmptyStatement(token); | 2201     listener.handleEmptyStatement(token); | 
| 2244     return expectSemicolon(token); | 2202     return expectSemicolon(token); | 
| 2245   } | 2203   } | 
| 2246 } | 2204 } | 
| OLD | NEW | 
|---|