| 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 library fasta.parser.parser; | 5 library fasta.parser.parser; |
| 6 | 6 |
| 7 import '../scanner.dart' show ErrorToken; | 7 import '../scanner.dart' show ErrorToken; |
| 8 | 8 |
| 9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; | 9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; |
| 10 | 10 |
| 11 import 'package:front_end/src/fasta/scanner/keyword.dart' show Keyword; | 11 import '../scanner/keyword.dart' show Keyword; |
| 12 | 12 |
| 13 import 'package:front_end/src/fasta/scanner/precedence.dart' | 13 import '../scanner/precedence.dart' |
| 14 show | 14 show |
| 15 ASSIGNMENT_PRECEDENCE, | 15 ASSIGNMENT_PRECEDENCE, |
| 16 AS_INFO, | 16 AS_INFO, |
| 17 CASCADE_PRECEDENCE, | 17 CASCADE_PRECEDENCE, |
| 18 EQUALITY_PRECEDENCE, | 18 EQUALITY_PRECEDENCE, |
| 19 GT_INFO, | 19 GT_INFO, |
| 20 IS_INFO, | 20 IS_INFO, |
| 21 MINUS_MINUS_INFO, | 21 MINUS_MINUS_INFO, |
| 22 OPEN_PAREN_INFO, | 22 OPEN_PAREN_INFO, |
| 23 OPEN_SQUARE_BRACKET_INFO, | 23 OPEN_SQUARE_BRACKET_INFO, |
| 24 PERIOD_INFO, | 24 PERIOD_INFO, |
| 25 PLUS_PLUS_INFO, | 25 PLUS_PLUS_INFO, |
| 26 POSTFIX_PRECEDENCE, | 26 POSTFIX_PRECEDENCE, |
| 27 PrecedenceInfo, | 27 PrecedenceInfo, |
| 28 QUESTION_INFO, | 28 QUESTION_INFO, |
| 29 QUESTION_PERIOD_INFO, | 29 QUESTION_PERIOD_INFO, |
| 30 RELATIONAL_PRECEDENCE; | 30 RELATIONAL_PRECEDENCE; |
| 31 | 31 |
| 32 import 'package:front_end/src/fasta/scanner/token.dart' | 32 import '../scanner/token.dart' |
| 33 show | 33 show |
| 34 BeginGroupToken, | 34 BeginGroupToken, |
| 35 KeywordToken, | 35 KeywordToken, |
| 36 SymbolToken, | 36 SymbolToken, |
| 37 Token, | 37 Token, |
| 38 isUserDefinableOperator; | 38 isUserDefinableOperator; |
| 39 | 39 |
| 40 import 'package:front_end/src/fasta/scanner/token_constants.dart' | 40 import '../scanner/token_constants.dart' |
| 41 show | 41 show |
| 42 COMMA_TOKEN, | 42 COMMA_TOKEN, |
| 43 DOUBLE_TOKEN, | 43 DOUBLE_TOKEN, |
| 44 EOF_TOKEN, | 44 EOF_TOKEN, |
| 45 EQ_TOKEN, | 45 EQ_TOKEN, |
| 46 FUNCTION_TOKEN, | 46 FUNCTION_TOKEN, |
| 47 GT_TOKEN, | 47 GT_TOKEN, |
| 48 GT_GT_TOKEN, | 48 GT_GT_TOKEN, |
| 49 HASH_TOKEN, | 49 HASH_TOKEN, |
| 50 HEXADECIMAL_TOKEN, | 50 HEXADECIMAL_TOKEN, |
| 51 IDENTIFIER_TOKEN, | 51 IDENTIFIER_TOKEN, |
| 52 INT_TOKEN, | 52 INT_TOKEN, |
| 53 KEYWORD_TOKEN, | 53 KEYWORD_TOKEN, |
| 54 LT_TOKEN, | 54 LT_TOKEN, |
| 55 OPEN_CURLY_BRACKET_TOKEN, | 55 OPEN_CURLY_BRACKET_TOKEN, |
| 56 OPEN_PAREN_TOKEN, | 56 OPEN_PAREN_TOKEN, |
| 57 OPEN_SQUARE_BRACKET_TOKEN, | 57 OPEN_SQUARE_BRACKET_TOKEN, |
| 58 PERIOD_TOKEN, | 58 PERIOD_TOKEN, |
| 59 SEMICOLON_TOKEN, | 59 SEMICOLON_TOKEN, |
| 60 STRING_INTERPOLATION_IDENTIFIER_TOKEN, | 60 STRING_INTERPOLATION_IDENTIFIER_TOKEN, |
| 61 STRING_INTERPOLATION_TOKEN, | 61 STRING_INTERPOLATION_TOKEN, |
| 62 STRING_TOKEN; | 62 STRING_TOKEN; |
| 63 | 63 |
| 64 import 'package:front_end/src/fasta/scanner/characters.dart' | 64 import '../scanner/characters.dart' show $CLOSE_CURLY_BRACKET; |
| 65 show $CLOSE_CURLY_BRACKET; | |
| 66 | 65 |
| 67 import 'package:front_end/src/fasta/util/link.dart' show Link; | 66 import '../util/link.dart' show Link; |
| 68 | 67 |
| 69 import 'listener.dart' show Listener; | 68 import 'listener.dart' show Listener; |
| 70 | 69 |
| 71 import 'error_kind.dart' show ErrorKind; | 70 import 'error_kind.dart' show ErrorKind; |
| 72 | 71 |
| 73 import 'identifier_context.dart' show IdentifierContext; | 72 import 'identifier_context.dart' show IdentifierContext; |
| 74 | 73 |
| 75 /// Returns true if [token] is the symbol or keyword [value]. | 74 /// Returns true if [token] is the symbol or keyword [value]. |
| 76 bool optional(String value, Token token) { | 75 bool optional(String value, Token token) { |
| 77 return identical(value, token.stringValue); | 76 return identical(value, token.stringValue); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 339 } |
| 341 | 340 |
| 342 Token parsePartOf(Token token) { | 341 Token parsePartOf(Token token) { |
| 343 listener.beginPartOf(token); | 342 listener.beginPartOf(token); |
| 344 assert(optional('part', token)); | 343 assert(optional('part', token)); |
| 345 assert(optional('of', token.next)); | 344 assert(optional('of', token.next)); |
| 346 Token partKeyword = token; | 345 Token partKeyword = token; |
| 347 token = token.next.next; | 346 token = token.next.next; |
| 348 if (token.isIdentifier()) { | 347 if (token.isIdentifier()) { |
| 349 token = parseQualified(token, IdentifierContext.partName, | 348 token = parseQualified(token, IdentifierContext.partName, |
| 350 IdentifierContext.partNameContinuation); | 349 IdentifierContext.partNameContinuation); |
| 351 } else { | 350 } else { |
| 352 token = parseLiteralStringOrRecoverExpression(token); | 351 token = parseLiteralStringOrRecoverExpression(token); |
| 353 } | 352 } |
| 354 Token semicolon = token; | 353 Token semicolon = token; |
| 355 token = expect(';', token); | 354 token = expect(';', token); |
| 356 listener.endPartOf(partKeyword, semicolon); | 355 listener.endPartOf(partKeyword, semicolon); |
| 357 return token; | 356 return token; |
| 358 } | 357 } |
| 359 | 358 |
| 360 Token parseMetadataStar(Token token, {bool forParameter: false}) { | 359 Token parseMetadataStar(Token token, {bool forParameter: false}) { |
| (...skipping 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3548 break; | 3547 break; |
| 3549 } | 3548 } |
| 3550 if (isRecoverable) { | 3549 if (isRecoverable) { |
| 3551 listener.handleRecoverableError(token, kind, arguments); | 3550 listener.handleRecoverableError(token, kind, arguments); |
| 3552 return null; | 3551 return null; |
| 3553 } else { | 3552 } else { |
| 3554 return listener.handleUnrecoverableError(token, kind, arguments); | 3553 return listener.handleUnrecoverableError(token, kind, arguments); |
| 3555 } | 3554 } |
| 3556 } | 3555 } |
| 3557 } | 3556 } |
| OLD | NEW |