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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 2794653002: fasta tokens implement analyzer token API (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
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 library analyzer.src.generated.parser; 5 library analyzer.src.generated.parser;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 parameters); 1558 parameters);
1559 } else if (_tokenMatches(next, TokenType.LT)) { 1559 } else if (_tokenMatches(next, TokenType.LT)) {
1560 return _parseMethodDeclarationAfterReturnType(commentAndMetadata, 1560 return _parseMethodDeclarationAfterReturnType(commentAndMetadata,
1561 modifiers.externalKeyword, modifiers.staticKeyword, type); 1561 modifiers.externalKeyword, modifiers.staticKeyword, type);
1562 } else if (_tokenMatches(next, TokenType.OPEN_CURLY_BRACKET)) { 1562 } else if (_tokenMatches(next, TokenType.OPEN_CURLY_BRACKET)) {
1563 // We have found "TypeName identifier {", and are guessing that this is a 1563 // We have found "TypeName identifier {", and are guessing that this is a
1564 // getter without the keyword 'get'. 1564 // getter without the keyword 'get'.
1565 _validateModifiersForGetterOrSetterOrMethod(modifiers); 1565 _validateModifiersForGetterOrSetterOrMethod(modifiers);
1566 _reportErrorForCurrentToken(ParserErrorCode.MISSING_GET); 1566 _reportErrorForCurrentToken(ParserErrorCode.MISSING_GET);
1567 _currentToken = _injectToken( 1567 _currentToken = _injectToken(
1568 new Parser_SyntheticKeywordToken(Keyword.GET, _currentToken.offset)); 1568 new SyntheticKeywordToken(Keyword.GET, _currentToken.offset));
1569 return parseGetter(commentAndMetadata, modifiers.externalKeyword, 1569 return parseGetter(commentAndMetadata, modifiers.externalKeyword,
1570 modifiers.staticKeyword, type); 1570 modifiers.staticKeyword, type);
1571 } 1571 }
1572 return parseInitializedIdentifierList( 1572 return parseInitializedIdentifierList(
1573 commentAndMetadata, 1573 commentAndMetadata,
1574 modifiers.staticKeyword, 1574 modifiers.staticKeyword,
1575 modifiers.covariantKeyword, 1575 modifiers.covariantKeyword,
1576 _validateModifiersForField(modifiers), 1576 _validateModifiersForField(modifiers),
1577 type); 1577 type);
1578 } 1578 }
(...skipping 4215 matching lines...) Expand 10 before | Expand all | Expand 10 after
5794 _matchesIdentifier()) { 5794 _matchesIdentifier()) {
5795 return true; 5795 return true;
5796 } 5796 }
5797 } 5797 }
5798 return false; 5798 return false;
5799 } 5799 }
5800 5800
5801 /** 5801 /**
5802 * Return a synthetic token representing the given [keyword]. 5802 * Return a synthetic token representing the given [keyword].
5803 */ 5803 */
5804 Token _createSyntheticKeyword(Keyword keyword) => _injectToken( 5804 Token _createSyntheticKeyword(Keyword keyword) =>
5805 new Parser_SyntheticKeywordToken(keyword, _currentToken.offset)); 5805 _injectToken(new SyntheticKeywordToken(keyword, _currentToken.offset));
5806 5806
5807 /** 5807 /**
5808 * Return a synthetic token with the given [type]. 5808 * Return a synthetic token with the given [type].
5809 */ 5809 */
5810 Token _createSyntheticToken(TokenType type) => 5810 Token _createSyntheticToken(TokenType type) =>
5811 _injectToken(new StringToken(type, "", _currentToken.offset)); 5811 _injectToken(new StringToken(type, "", _currentToken.offset));
5812 5812
5813 /** 5813 /**
5814 * Create and return a new token with the given [type]. The token will replace 5814 * Create and return a new token with the given [type]. The token will replace
5815 * the first portion of the given [token], so it will have the same offset and 5815 * the first portion of the given [token], so it will have the same offset and
(...skipping 2682 matching lines...) Expand 10 before | Expand all | Expand 10 after
8498 } 8498 }
8499 if (modifiers.finalKeyword != null) { 8499 if (modifiers.finalKeyword != null) {
8500 _reportErrorForToken( 8500 _reportErrorForToken(
8501 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword); 8501 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword);
8502 } 8502 }
8503 if (modifiers.varKeyword != null) { 8503 if (modifiers.varKeyword != null) {
8504 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); 8504 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword);
8505 } 8505 }
8506 } 8506 }
8507 } 8507 }
8508
8509 /**
8510 * A synthetic keyword token.
8511 */
8512 class Parser_SyntheticKeywordToken extends KeywordToken {
8513 /**
8514 * Initialize a newly created token to represent the given [keyword] at the
8515 * given [offset].
8516 */
8517 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
8518 : super(keyword, offset);
8519
8520 @override
8521 int get length => 0;
8522
8523 @override
8524 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
8525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698