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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.analyzer.ast_builder; 5 library fasta.analyzer.ast_builder;
6 6
7 import 'package:front_end/src/fasta/scanner/token.dart' 7 import 'package:front_end/src/fasta/scanner/token.dart'
8 show BeginGroupToken, Token; 8 show BeginGroupToken, Token;
9 9
10 import 'package:analyzer/analyzer.dart'; 10 import 'package:analyzer/analyzer.dart';
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 beginToken, scriptTag, directives, declarations, endToken)); 693 beginToken, scriptTag, directives, declarations, endToken));
694 } 694 }
695 695
696 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, 696 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword,
697 Token semicolon) { 697 Token semicolon) {
698 debugEvent("Import"); 698 debugEvent("Import");
699 List<Combinator> combinators = pop(); 699 List<Combinator> combinators = pop();
700 SimpleIdentifier prefix; 700 SimpleIdentifier prefix;
701 if (asKeyword != null) prefix = pop(); 701 if (asKeyword != null) prefix = pop();
702 List<Configuration> configurations = pop(); 702 List<Configuration> configurations = pop();
703 assert(configurations == null); // TODO(paulberry)
704 StringLiteral uri = pop(); 703 StringLiteral uri = pop();
705 List<Annotation> metadata = pop(); 704 List<Annotation> metadata = pop();
706 assert(metadata == null); 705 assert(metadata == null);
707 // TODO(paulberry): capture doc comments. 706 // TODO(paulberry): capture doc comments.
708 Comment comment = null; 707 Comment comment = null;
709 push(ast.importDirective( 708 push(ast.importDirective(
710 comment, 709 comment,
711 metadata, 710 metadata,
712 toAnalyzerToken(importKeyword), 711 toAnalyzerToken(importKeyword),
713 uri, 712 uri,
714 configurations, 713 configurations,
715 toAnalyzerToken(deferredKeyword), 714 toAnalyzerToken(deferredKeyword),
716 toAnalyzerToken(asKeyword), 715 toAnalyzerToken(asKeyword),
717 prefix, 716 prefix,
718 combinators, 717 combinators,
719 toAnalyzerToken(semicolon))); 718 toAnalyzerToken(semicolon)));
720 } 719 }
721 720
722 void endExport(Token exportKeyword, Token semicolon) { 721 void endExport(Token exportKeyword, Token semicolon) {
723 debugEvent("Export"); 722 debugEvent("Export");
724 List<Combinator> combinators = pop(); 723 List<Combinator> combinators = pop();
725 List<Configuration> configurations = pop(); 724 List<Configuration> configurations = pop();
726 assert(configurations == null); // TODO(paulberry)
727 StringLiteral uri = pop(); 725 StringLiteral uri = pop();
728 List<Annotation> metadata = pop(); 726 List<Annotation> metadata = pop();
729 assert(metadata == null); 727 assert(metadata == null);
730 // TODO(paulberry): capture doc comments. 728 // TODO(paulberry): capture doc comments.
731 Comment comment = null; 729 Comment comment = null;
732 push(ast.exportDirective(comment, metadata, toAnalyzerToken(exportKeyword), 730 push(ast.exportDirective(comment, metadata, toAnalyzerToken(exportKeyword),
733 uri, configurations, combinators, toAnalyzerToken(semicolon))); 731 uri, configurations, combinators, toAnalyzerToken(semicolon)));
734 } 732 }
735 733
736 @override 734 @override
735 void endDottedName(int count, Token firstIdentifier) {
736 debugEvent("DottedName");
737 List<SimpleIdentifier> components = popList(count);
738 push(ast.dottedName(components));
739 }
740
741 void endConditionalUri(Token ifKeyword, Token equalitySign) {
742 debugEvent("ConditionalUri");
743 StringLiteral libraryUri = pop();
744 // TODO(paulberry,ahe): the parser should report the right paren token to
745 // the listener.
ahe 2017/02/22 05:58:53 That would be ifKeyword.next.endGroup.
746 Token rightParen = null;
747 StringLiteral value;
748 if (equalitySign != null) {
749 value = pop();
750 }
751 DottedName name = pop();
752 // TODO(paulberry,ahe): what if there is no `(` token due to an error in the
753 // file being parsed? It seems like we need the parser to do adequate error
754 // recovery and then report both the ifKeyword and leftParen tokens to the
755 // listener.
756 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
757 push(ast.configuration(
758 toAnalyzerToken(ifKeyword),
759 toAnalyzerToken(leftParen),
760 name,
761 toAnalyzerToken(equalitySign),
762 value,
763 toAnalyzerToken(rightParen),
764 libraryUri));
765 }
766
767 @override
737 void endConditionalUris(int count) { 768 void endConditionalUris(int count) {
738 debugEvent("ConditionalUris"); 769 debugEvent("ConditionalUris");
739 push(popList(count) ?? NullValue.ConditionalUris); 770 push(popList(count) ?? NullValue.ConditionalUris);
740 } 771 }
741 772
742 @override 773 @override
743 void endIdentifierList(int count) { 774 void endIdentifierList(int count) {
744 debugEvent("IdentifierList"); 775 debugEvent("IdentifierList");
745 push(popList(count) ?? NullValue.IdentifierList); 776 push(popList(count) ?? NullValue.IdentifierList);
746 } 777 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 /// [ClassDeclaration] or [ClassTypeAlias] object. 1153 /// [ClassDeclaration] or [ClassTypeAlias] object.
1123 class _MixinApplication { 1154 class _MixinApplication {
1124 final TypeName supertype; 1155 final TypeName supertype;
1125 1156
1126 final Token withKeyword; 1157 final Token withKeyword;
1127 1158
1128 final List<TypeName> mixinTypes; 1159 final List<TypeName> mixinTypes;
1129 1160
1130 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes); 1161 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes);
1131 } 1162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698