diff --git a/pkg/analyzer/test/generated/parser_fasta_test.dart b/pkg/analyzer/test/generated/parser_fasta_test.dart index eb8b5f90c1c..c88d82b1aa0 100644 --- a/pkg/analyzer/test/generated/parser_fasta_test.dart +++ b/pkg/analyzer/test/generated/parser_fasta_test.dart @@ -667,12 +667,6 @@ class ExpressionParserTest_Fasta extends FastaParserTestCase super.test_parseSuperConstructorInvocation_unnamed(); } - @override - @failingTest - void test_parseSymbolLiteral_operator() { - super.test_parseSymbolLiteral_operator(); - } - @override @failingTest void test_parseSymbolLiteral_void() { 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 c2d1c6742c9..8eda5e59bbc 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 components = new List(identifierCount); - for (int i = identifierCount - 1; i >= 0; i--) { - SimpleIdentifier identifier = pop(); - components[i] = identifier.token; - } + List components = popList(tokenCount); push(ast.symbolLiteral(toAnalyzerToken(hashToken), components)); } diff --git a/pkg/front_end/lib/src/fasta/parser/identifier_context.dart b/pkg/front_end/lib/src/fasta/parser/identifier_context.dart index 9a9d774952f..276bd0be992 100644 --- a/pkg/front_end/lib/src/fasta/parser/identifier_context.dart +++ b/pkg/front_end/lib/src/fasta/parser/identifier_context.dart @@ -200,12 +200,13 @@ class IdentifierContext { /// Identifier is the start of a reference occurring in a literal symbol (e.g. /// `foo` in `#foo`). static const literalSymbol = - const IdentifierContext._('literalSymbol', isScopeReference: true); + const IdentifierContext._('literalSymbol', inSymbol: true); /// Identifier is part of a reference occurring in a literal symbol, but it's /// not the first identifier of the reference (e.g. `foo` in `#prefix.foo`). static const literalSymbolContinuation = const IdentifierContext._( 'literalSymbolContinuation', + inSymbol: true, isContinuation: true); /// Identifier appears in an expression, and it does not immediately follow a @@ -236,6 +237,9 @@ class IdentifierContext { /// declaration. final bool inLibraryOrPartOfDeclaration; + /// Indicates whether the identifier is within a symbol literal. + final bool inSymbol; + /// Indicates whether the identifier follows a `.`. final bool isContinuation; @@ -244,6 +248,7 @@ class IdentifierContext { const IdentifierContext._(this._name, {this.inLibraryOrPartOfDeclaration: false, + this.inSymbol: false, this.isContinuation: false, this.isScopeReference: false});