Chromium Code Reviews| 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 97d19b158ff889bb032dbd180d632777e1ab3b75..33c595c6f0f95785295c955280cc73ba18443cf6 100644 |
| --- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
| +++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
| @@ -121,6 +121,13 @@ class AstBuilder extends ScopeListener { |
| } else { |
| push(identifier); |
| } |
| + } else if (context == IdentifierContext.enumValueDeclaration) { |
| + // TODO(paulberry): analyzer's ASTs allow for enumerated values to have |
| + // metadata, but the spec doesn't permit it. |
|
ahe
2017/02/23 16:47:25
I think we should accept it for error recovery.
|
| + List<Annotation> metadata; |
| + // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
| + Comment comment = null; |
| + push(ast.enumConstantDeclaration(comment, metadata, identifier)); |
| } else { |
| if (context.isScopeReference) { |
| Builder builder = scope.lookup(name, token.charOffset, uri); |
| @@ -1078,6 +1085,28 @@ class AstBuilder extends ScopeListener { |
| toAnalyzerToken(endToken))); |
| } |
| + void endEnum(Token enumKeyword, Token endBrace, int count) { |
| + debugEvent("Enum"); |
| + List<EnumConstantDeclaration> constants = popList(count); |
| + // TODO(paulberry,ahe): the parser should pass in the openBrace token. |
| + var openBrace = enumKeyword.next.next as BeginGroupToken; |
|
ahe
2017/02/23 16:47:25
I would recommend against casts as they have to be
|
| + // TODO(paulberry): what if the '}' is missing and the parser has performed |
| + // error recovery? |
|
ahe
2017/02/23 16:47:25
The scanner always provides a synthetic end token.
|
| + Token closeBrace = openBrace.endGroup; |
| + SimpleIdentifier name = pop(); |
| + List<Annotation> metadata = pop(); |
| + // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
| + Comment comment = null; |
| + push(ast.enumDeclaration( |
| + comment, |
| + metadata, |
| + toAnalyzerToken(enumKeyword), |
| + name, |
| + toAnalyzerToken(openBrace), |
| + constants, |
| + toAnalyzerToken(closeBrace))); |
| + } |
| + |
| /** |
| * Pop the modifiers list, if the list is empty return `null`, if the list |
| * has one item return it; otherwise return `null`. |