| OLD | NEW |
| 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; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 bool notEofOrValue(String value, Token token) { | 290 bool notEofOrValue(String value, Token token) { |
| 291 return token.kind !== EOF_TOKEN && value !== token.stringValue; | 291 return token.kind !== EOF_TOKEN && value !== token.stringValue; |
| 292 } | 292 } |
| 293 | 293 |
| 294 Token parseType(Token token) { | 294 Token parseType(Token token) { |
| 295 // TODO(ahe): Rename this method to parseTypeOrVar? | 295 // TODO(ahe): Rename this method to parseTypeOrVar? |
| 296 Token begin = token; | 296 Token begin = token; |
| 297 int identifierCount = 1; | 297 int identifierCount = 1; |
| 298 if (isIdentifier(token)) { | 298 if (isIdentifier(token)) { |
| 299 token = parseIdentifier(token); | 299 token = parseIdentifier(token); |
| 300 while (optional('.', token)) { | 300 if (optional('.', token)) { |
| 301 // TODO(ahe): Validate that there are at most two identifiers. | |
| 302 token = parseIdentifier(token.next); | 301 token = parseIdentifier(token.next); |
| 303 ++identifierCount; | 302 ++identifierCount; |
| 304 } | 303 } |
| 305 } else { | 304 } else { |
| 306 token = listener.expectedType(token); | 305 token = listener.expectedType(token); |
| 307 } | 306 } |
| 308 token = parseTypeArgumentsOpt(token); | 307 token = parseTypeArgumentsOpt(token); |
| 309 listener.endType(identifierCount, begin, token); | 308 listener.endType(identifierCount, begin, token); |
| 310 return token; | 309 return token; |
| 311 } | 310 } |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 } | 1651 } |
| 1653 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 1652 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 1654 return expectSemicolon(token); | 1653 return expectSemicolon(token); |
| 1655 } | 1654 } |
| 1656 | 1655 |
| 1657 Token parseEmptyStatement(Token token) { | 1656 Token parseEmptyStatement(Token token) { |
| 1658 listener.handleEmptyStatement(token); | 1657 listener.handleEmptyStatement(token); |
| 1659 return expectSemicolon(token); | 1658 return expectSemicolon(token); |
| 1660 } | 1659 } |
| 1661 } | 1660 } |
| OLD | NEW |