| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.parser; | 8 library engine.parser; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2991 */ | 2991 */ |
| 2992 void _ensureAssignable(Expression expression) { | 2992 void _ensureAssignable(Expression expression) { |
| 2993 if (expression != null && !expression.isAssignable) { | 2993 if (expression != null && !expression.isAssignable) { |
| 2994 _reportErrorForCurrentToken(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSI
GNABLE, []); | 2994 _reportErrorForCurrentToken(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSI
GNABLE, []); |
| 2995 } | 2995 } |
| 2996 } | 2996 } |
| 2997 | 2997 |
| 2998 /** | 2998 /** |
| 2999 * If the current token has the expected type, return it after advancing to th
e next token. | 2999 * If the current token has the expected type, return it after advancing to th
e next token. |
| 3000 * Otherwise report an error and return the current token without advancing. N
ote that the method | 3000 * Otherwise report an error and return the current token without advancing. N
ote that the method |
| 3001 * [expectGt] should be used if the argument to this method would be [TokenTyp
e#GT] | 3001 * [_expectGt] should be used if the argument to this method would be [TokenTy
pe.GT]. |
| 3002 * . | |
| 3003 * | 3002 * |
| 3004 * @param type the type of token that is expected | 3003 * @param type the type of token that is expected |
| 3005 * @return the token that matched the given type | 3004 * @return the token that matched the given type |
| 3006 */ | 3005 */ |
| 3007 Token _expect(TokenType type) { | 3006 Token _expect(TokenType type) { |
| 3008 if (_matches(type)) { | 3007 if (_matches(type)) { |
| 3009 return andAdvance; | 3008 return andAdvance; |
| 3010 } | 3009 } |
| 3011 // Remove uses of this method in favor of matches? | 3010 // Remove uses of this method in favor of matches? |
| 3012 // Pass in the error code to use to report the error? | 3011 // Pass in the error code to use to report the error? |
| 3013 if (type == TokenType.SEMICOLON) { | 3012 if (type == TokenType.SEMICOLON) { |
| 3014 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previou
s, [type.lexeme]); | 3013 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previou
s, [type.lexeme]); |
| 3015 } else { | 3014 } else { |
| 3016 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [type.lexeme])
; | 3015 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [type.lexeme])
; |
| 3017 } | 3016 } |
| 3018 return _currentToken; | 3017 return _currentToken; |
| 3019 } | 3018 } |
| 3020 | 3019 |
| 3021 /** | 3020 /** |
| 3022 * If the current token has the type [TokenType#GT], return it after advancing
to the next | 3021 * If the current token has the type [TokenType.GT], return it after advancing
to the next |
| 3023 * token. Otherwise report an error and return the current token without advan
cing. | 3022 * token. Otherwise report an error and return the current token without advan
cing. |
| 3024 * | 3023 * |
| 3025 * @return the token that matched the given type | 3024 * @return the token that matched the given type |
| 3026 */ | 3025 */ |
| 3027 Token _expectGt() { | 3026 Token _expectGt() { |
| 3028 if (_matchesGt()) { | 3027 if (_matchesGt()) { |
| 3029 return andAdvance; | 3028 return andAdvance; |
| 3030 } | 3029 } |
| 3031 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [TokenType.GT.le
xeme]); | 3030 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [TokenType.GT.le
xeme]); |
| 3032 return _currentToken; | 3031 return _currentToken; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3452 /** | 3451 /** |
| 3453 * Increments the error reporting lock level. If level is more than `0`, then | 3452 * Increments the error reporting lock level. If level is more than `0`, then |
| 3454 * [reportError] wont report any error. | 3453 * [reportError] wont report any error. |
| 3455 */ | 3454 */ |
| 3456 void _lockErrorListener() { | 3455 void _lockErrorListener() { |
| 3457 _errorListenerLock++; | 3456 _errorListenerLock++; |
| 3458 } | 3457 } |
| 3459 | 3458 |
| 3460 /** | 3459 /** |
| 3461 * Return `true` if the current token has the given type. Note that the method | 3460 * Return `true` if the current token has the given type. Note that the method |
| 3462 * [matchesGt] should be used if the argument to this method would be | 3461 * [_matchesGt] should be used if the argument to this method would be |
| 3463 * [TokenType#GT]. | 3462 * [TokenType.GT]. |
| 3464 * | 3463 * |
| 3465 * @param type the type of token that can optionally appear in the current loc
ation | 3464 * @param type the type of token that can optionally appear in the current loc
ation |
| 3466 * @return `true` if the current token has the given type | 3465 * @return `true` if the current token has the given type |
| 3467 */ | 3466 */ |
| 3468 bool _matches(TokenType type) => _currentToken.type == type; | 3467 bool _matches(TokenType type) => _currentToken.type == type; |
| 3469 | 3468 |
| 3470 /** | 3469 /** |
| 3471 * Return `true` if the current token has a type of [TokenType#GT]. Note that
this | 3470 * Return `true` if the current token has a type of [TokenType.GT]. Note that
this |
| 3472 * method, unlike other variants, will modify the token stream if possible to
match desired type. | 3471 * method, unlike other variants, will modify the token stream if possible to
match desired type. |
| 3473 * In particular, if the next token is either a '>>' or '>>>', the token strea
m will be re-written | 3472 * In particular, if the next token is either a '>>' or '>>>', the token strea
m will be re-written |
| 3474 * and `true` will be returned. | 3473 * and `true` will be returned. |
| 3475 * | 3474 * |
| 3476 * @return `true` if the current token has a type of [TokenType#GT] | 3475 * @return `true` if the current token has a type of [TokenType.GT] |
| 3477 */ | 3476 */ |
| 3478 bool _matchesGt() { | 3477 bool _matchesGt() { |
| 3479 TokenType currentType = _currentToken.type; | 3478 TokenType currentType = _currentToken.type; |
| 3480 if (currentType == TokenType.GT) { | 3479 if (currentType == TokenType.GT) { |
| 3481 return true; | 3480 return true; |
| 3482 } else if (currentType == TokenType.GT_GT) { | 3481 } else if (currentType == TokenType.GT_GT) { |
| 3483 int offset = _currentToken.offset; | 3482 int offset = _currentToken.offset; |
| 3484 Token first = new Token(TokenType.GT, offset); | 3483 Token first = new Token(TokenType.GT, offset); |
| 3485 Token second = new Token(TokenType.GT, offset + 1); | 3484 Token second = new Token(TokenType.GT, offset + 1); |
| 3486 second.setNext(_currentToken.next); | 3485 second.setNext(_currentToken.next); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 * Return `true` if the current token matches the given identifier. | 3531 * Return `true` if the current token matches the given identifier. |
| 3533 * | 3532 * |
| 3534 * @param identifier the identifier that can optionally appear in the current
location | 3533 * @param identifier the identifier that can optionally appear in the current
location |
| 3535 * @return `true` if the current token matches the given identifier | 3534 * @return `true` if the current token matches the given identifier |
| 3536 */ | 3535 */ |
| 3537 bool _matchesString(String identifier) => _currentToken.type == TokenType.IDEN
TIFIER && _currentToken.lexeme == identifier; | 3536 bool _matchesString(String identifier) => _currentToken.type == TokenType.IDEN
TIFIER && _currentToken.lexeme == identifier; |
| 3538 | 3537 |
| 3539 /** | 3538 /** |
| 3540 * If the current token has the given type, then advance to the next token and
return `true` | 3539 * If the current token has the given type, then advance to the next token and
return `true` |
| 3541 * . Otherwise, return `false` without advancing. This method should not be in
voked with an | 3540 * . Otherwise, return `false` without advancing. This method should not be in
voked with an |
| 3542 * argument value of [TokenType#GT]. | 3541 * argument value of [TokenType.GT]. |
| 3543 * | 3542 * |
| 3544 * @param type the type of token that can optionally appear in the current loc
ation | 3543 * @param type the type of token that can optionally appear in the current loc
ation |
| 3545 * @return `true` if the current token has the given type | 3544 * @return `true` if the current token has the given type |
| 3546 */ | 3545 */ |
| 3547 bool _optional(TokenType type) { | 3546 bool _optional(TokenType type) { |
| 3548 if (_matches(type)) { | 3547 if (_matches(type)) { |
| 3549 _advance(); | 3548 _advance(); |
| 3550 return true; | 3549 return true; |
| 3551 } | 3550 } |
| 3552 return false; | 3551 return false; |
| (...skipping 6229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9782 return trampoline(target, arguments[0], arguments[1]); | 9781 return trampoline(target, arguments[0], arguments[1]); |
| 9783 case 3: | 9782 case 3: |
| 9784 return trampoline(target, arguments[0], arguments[1], arguments[2]); | 9783 return trampoline(target, arguments[0], arguments[1], arguments[2]); |
| 9785 case 4: | 9784 case 4: |
| 9786 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); | 9785 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); |
| 9787 default: | 9786 default: |
| 9788 throw new IllegalArgumentException("Not implemented for > 4 arguments"); | 9787 throw new IllegalArgumentException("Not implemented for > 4 arguments"); |
| 9789 } | 9788 } |
| 9790 } | 9789 } |
| 9791 } | 9790 } |
| OLD | NEW |