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

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

Issue 2709623004: Add AstBuilder support for DottedName and ConditionalUri. (Closed)
Patch Set: Reformat Created 3 years, 10 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 5e9603f95a2ab007f6baf4c911d04bb776198cd0..c93ca97812a3010cc0dd92e7abdd6ff879a1b56b 100644
--- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
+++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
@@ -700,7 +700,6 @@ class AstBuilder extends ScopeListener {
SimpleIdentifier prefix;
if (asKeyword != null) prefix = pop();
List<Configuration> configurations = pop();
- assert(configurations == null); // TODO(paulberry)
StringLiteral uri = pop();
List<Annotation> metadata = pop();
assert(metadata == null);
@@ -723,7 +722,6 @@ class AstBuilder extends ScopeListener {
debugEvent("Export");
List<Combinator> combinators = pop();
List<Configuration> configurations = pop();
- assert(configurations == null); // TODO(paulberry)
StringLiteral uri = pop();
List<Annotation> metadata = pop();
assert(metadata == null);
@@ -734,6 +732,39 @@ class AstBuilder extends ScopeListener {
}
@override
+ void endDottedName(int count, Token firstIdentifier) {
+ debugEvent("DottedName");
+ List<SimpleIdentifier> components = popList(count);
+ push(ast.dottedName(components));
+ }
+
+ void endConditionalUri(Token ifKeyword, Token equalitySign) {
+ debugEvent("ConditionalUri");
+ StringLiteral libraryUri = pop();
+ // TODO(paulberry,ahe): the parser should report the right paren token to
+ // the listener.
ahe 2017/02/22 05:58:53 That would be ifKeyword.next.endGroup.
+ Token rightParen = null;
+ StringLiteral value;
+ if (equalitySign != null) {
+ value = pop();
+ }
+ DottedName name = pop();
+ // TODO(paulberry,ahe): what if there is no `(` token due to an error in the
+ // file being parsed? It seems like we need the parser to do adequate error
+ // recovery and then report both the ifKeyword and leftParen tokens to the
+ // listener.
+ Token leftParen = ifKeyword.next;
ahe 2017/02/22 05:58:53 The scanner should have set up the token stream so
Paul Berry 2017/02/22 21:20:13 I think you're answering the question "what if the
ahe 2017/02/23 17:51:52 Yes. I answered "what if there's no close parenthe
+ push(ast.configuration(
+ toAnalyzerToken(ifKeyword),
+ toAnalyzerToken(leftParen),
+ name,
+ toAnalyzerToken(equalitySign),
+ value,
+ toAnalyzerToken(rightParen),
+ libraryUri));
+ }
+
+ @override
void endConditionalUris(int count) {
debugEvent("ConditionalUris");
push(popList(count) ?? NullValue.ConditionalUris);

Powered by Google App Engine
This is Rietveld 408576698