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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/token.dart

Issue 2762103003: fasta.BeginGroupToken implement analyzer.BeginToken (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/fasta/token_utils.dart ('k') | pkg/front_end/test/precedence_info_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/scanner/token.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/token.dart b/pkg/front_end/lib/src/fasta/scanner/token.dart
index e6d6b3498943b02de498a27d364c083ca25f970a..5a3d78548f0a3290b47620477bbcacc3dd56e19b 100644
--- a/pkg/front_end/lib/src/fasta/scanner/token.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/token.dart
@@ -8,7 +8,17 @@ import '../../scanner/token.dart' as analyzer;
import 'keyword.dart' show Keyword;
-import 'precedence.dart' show BAD_INPUT_INFO, EOF_INFO, PrecedenceInfo;
+import 'precedence.dart'
+ show
+ AS_INFO,
+ BAD_INPUT_INFO,
+ EOF_INFO,
+ IDENTIFIER_INFO,
+ IS_INFO,
+ KEYWORD_INFO,
+ MULTI_LINE_COMMENT_INFO,
+ SINGLE_LINE_COMMENT_INFO,
+ PrecedenceInfo;
import 'token_constants.dart' show IDENTIFIER_TOKEN;
@@ -145,7 +155,10 @@ abstract class Token implements analyzer.TokenWithComment {
bool get isUserDefinableOperator => info.isUserDefinableOperator;
@override
- analyzer.TokenType get type => info;
+ analyzer.TokenType get type {
+ // Analyzer has a different concept of what is a Keyword type.
+ return info == AS_INFO || info == IS_INFO ? KEYWORD_INFO : info;
+ }
@override
int get offset => charOffset;
@@ -265,11 +278,19 @@ class SymbolToken extends Token {
* The [endGroup] token points to the matching closing bracked in case
* it can be identified during scanning.
*/
-class BeginGroupToken extends SymbolToken {
+class BeginGroupToken extends SymbolToken implements analyzer.BeginToken {
Token endGroup;
BeginGroupToken(PrecedenceInfo info, int charOffset)
: super(info, charOffset);
+
+ @override
+ analyzer.Token get endToken => endGroup;
+
+ @override
+ void set endToken(analyzer.Token token) {
+ endGroup = token as Token;
Paul Berry 2017/03/21 14:16:01 This cast shouldn't be required now that the dynam
danrubel 2017/03/21 15:49:24 Done.
+ }
}
/**
@@ -302,7 +323,22 @@ class KeywordToken extends Token {
Token copyWithoutComments() => new KeywordToken(keyword, charOffset);
@override
- Object value() => keyword;
+ Object value() {
+ // Analyzer has different set of keyword tokens
+ // TODO(danrubel): Remove special case for "deferred" once dartbug.com/29069
+ // is fixed.
+ return isPseudo && !identical("deferred", lexeme) ? lexeme : keyword;
+ }
+
+ @override
+ analyzer.TokenType get type {
+ // Analyzer considers pseudo-keywords to be identifiers
+ // TODO(danrubel): Remove special case for "deferred" once dartbug.com/29069
+ // is fixed.
+ return isPseudo && !identical("deferred", lexeme)
+ ? IDENTIFIER_INFO
+ : KEYWORD_INFO;
+ }
}
/**
« no previous file with comments | « pkg/analyzer/lib/src/fasta/token_utils.dart ('k') | pkg/front_end/test/precedence_info_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698