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

Unified Diff: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart

Issue 2735623002: Parse #operator symbol literals with Fasta. (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
Index: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
index c2d1c6742c9aa89c7e2b5ab1612623a405e18338..8eda5e59bbc29abcd5398edbc659b47ca61eace5 100644
--- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
+++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
@@ -149,8 +149,14 @@ class AstBuilder extends ScopeListener {
void handleIdentifier(Token token, IdentifierContext context) {
debugEvent("handleIdentifier");
- String name = token.value;
- SimpleIdentifier identifier = ast.simpleIdentifier(toAnalyzerToken(token));
+ analyzer.Token analyzerToken = toAnalyzerToken(token);
+
+ if (context.inSymbol) {
+ push(analyzerToken);
+ return;
+ }
+
+ SimpleIdentifier identifier = ast.simpleIdentifier(analyzerToken);
if (context.inLibraryOrPartOfDeclaration) {
if (!context.isContinuation) {
push([identifier]);
@@ -166,6 +172,7 @@ class AstBuilder extends ScopeListener {
push(ast.enumConstantDeclaration(comment, metadata, identifier));
} else {
if (context.isScopeReference) {
+ String name = token.value;
Builder builder = scope.lookup(name, token.charOffset, uri);
if (builder != null) {
Element element = elementStore[builder];
@@ -263,6 +270,11 @@ class AstBuilder extends ScopeListener {
push(receiver);
}
+ void handleOperator(Token token) {
+ debugEvent("Operator");
+ push(toAnalyzerToken(token));
+ }
+
void handleBinaryExpression(Token token) {
debugEvent("BinaryExpression");
if (identical(".", token.stringValue) ||
@@ -487,13 +499,9 @@ class AstBuilder extends ScopeListener {
push(ast.mapLiteralEntry(key, toAnalyzerToken(colon), value));
}
- void endLiteralSymbol(Token hashToken, int identifierCount) {
+ void endLiteralSymbol(Token hashToken, int tokenCount) {
debugEvent("LiteralSymbol");
- List<analyzer.Token> components = new List<analyzer.Token>(identifierCount);
- for (int i = identifierCount - 1; i >= 0; i--) {
- SimpleIdentifier identifier = pop();
- components[i] = identifier.token;
- }
+ List<analyzer.Token> components = popList(tokenCount);
push(ast.symbolLiteral(toAnalyzerToken(hashToken), components));
}

Powered by Google App Engine
This is Rietveld 408576698