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

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

Issue 2800583002: move fasta.Keyword methods to analyzer.Keyword (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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/enum_creator.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3971 matching lines...) Expand 10 before | Expand all | Expand 10 after
3982 TokenType type = _currentToken.type; 3982 TokenType type = _currentToken.type;
3983 if (type == TokenType.OPEN_CURLY_BRACKET) { 3983 if (type == TokenType.OPEN_CURLY_BRACKET) {
3984 if (_tokenMatches(_peek(), TokenType.STRING)) { 3984 if (_tokenMatches(_peek(), TokenType.STRING)) {
3985 Token afterString = skipStringLiteral(_currentToken.next); 3985 Token afterString = skipStringLiteral(_currentToken.next);
3986 if (afterString != null && afterString.type == TokenType.COLON) { 3986 if (afterString != null && afterString.type == TokenType.COLON) {
3987 return astFactory.expressionStatement( 3987 return astFactory.expressionStatement(
3988 parseExpression2(), _expect(TokenType.SEMICOLON)); 3988 parseExpression2(), _expect(TokenType.SEMICOLON));
3989 } 3989 }
3990 } 3990 }
3991 return parseBlock(); 3991 return parseBlock();
3992 } else if (type == TokenType.KEYWORD && 3992 } else if (type == TokenType.KEYWORD && !_currentToken.keyword.isBuiltIn) {
3993 !_currentToken.keyword.isPseudoKeyword) {
3994 Keyword keyword = _currentToken.keyword; 3993 Keyword keyword = _currentToken.keyword;
3995 // TODO(jwren) compute some metrics to figure out a better order for this 3994 // TODO(jwren) compute some metrics to figure out a better order for this
3996 // if-then sequence to optimize performance 3995 // if-then sequence to optimize performance
3997 if (keyword == Keyword.ASSERT) { 3996 if (keyword == Keyword.ASSERT) {
3998 return parseAssertStatement(); 3997 return parseAssertStatement();
3999 } else if (keyword == Keyword.BREAK) { 3998 } else if (keyword == Keyword.BREAK) {
4000 return parseBreakStatement(); 3999 return parseBreakStatement();
4001 } else if (keyword == Keyword.CONTINUE) { 4000 } else if (keyword == Keyword.CONTINUE) {
4002 return parseContinueStatement(); 4001 return parseContinueStatement();
4003 } else if (keyword == Keyword.DO) { 4002 } else if (keyword == Keyword.DO) {
(...skipping 3983 matching lines...) Expand 10 before | Expand all | Expand 10 after
7987 /** 7986 /**
7988 * Return `true` if the given [token] matches the given [keyword]. 7987 * Return `true` if the given [token] matches the given [keyword].
7989 */ 7988 */
7990 bool _tokenMatchesKeyword(Token token, Keyword keyword) => 7989 bool _tokenMatchesKeyword(Token token, Keyword keyword) =>
7991 token.keyword == keyword; 7990 token.keyword == keyword;
7992 7991
7993 /** 7992 /**
7994 * Return `true` if the given [token] matches a pseudo keyword. 7993 * Return `true` if the given [token] matches a pseudo keyword.
7995 */ 7994 */
7996 bool _tokenMatchesPseudoKeyword(Token token) => 7995 bool _tokenMatchesPseudoKeyword(Token token) =>
7997 token.keyword?.isPseudoKeyword ?? false; 7996 token.keyword?.isBuiltIn ?? false;
7998 7997
7999 /** 7998 /**
8000 * Return `true` if the given [token] matches the given [identifier]. 7999 * Return `true` if the given [token] matches the given [identifier].
8001 */ 8000 */
8002 bool _tokenMatchesString(Token token, String identifier) => 8001 bool _tokenMatchesString(Token token, String identifier) =>
8003 token.type == TokenType.IDENTIFIER && token.lexeme == identifier; 8002 token.type == TokenType.IDENTIFIER && token.lexeme == identifier;
8004 8003
8005 /** 8004 /**
8006 * Translate the characters at the given [index] in the given [lexeme], 8005 * Translate the characters at the given [index] in the given [lexeme],
8007 * appending the translated character to the given [buffer]. The index is 8006 * appending the translated character to the given [buffer]. The index is
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
8498 } 8497 }
8499 if (modifiers.finalKeyword != null) { 8498 if (modifiers.finalKeyword != null) {
8500 _reportErrorForToken( 8499 _reportErrorForToken(
8501 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword); 8500 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword);
8502 } 8501 }
8503 if (modifiers.varKeyword != null) { 8502 if (modifiers.varKeyword != null) {
8504 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); 8503 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword);
8505 } 8504 }
8506 } 8505 }
8507 } 8506 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/enum_creator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698