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

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

Issue 2738693004: Parse script tags 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 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:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 internalError( 137 internalError(
138 "Unexpected part in string interpolation: ${part.runtimeType}"); 138 "Unexpected part in string interpolation: ${part.runtimeType}");
139 } 139 }
140 } 140 }
141 elements.add(ast.interpolationString( 141 elements.add(ast.interpolationString(
142 toAnalyzerToken(last), unescapeLastStringPart(last.value, quote))); 142 toAnalyzerToken(last), unescapeLastStringPart(last.value, quote)));
143 push(ast.stringInterpolation(elements)); 143 push(ast.stringInterpolation(elements));
144 } 144 }
145 } 145 }
146 146
147 void handleScript(Token token) {
148 debugEvent("Script");
149 push(ast.scriptTag(toAnalyzerToken(token)));
150 }
151
147 void handleStringJuxtaposition(int literalCount) { 152 void handleStringJuxtaposition(int literalCount) {
148 debugEvent("StringJuxtaposition"); 153 debugEvent("StringJuxtaposition");
149 push(ast.adjacentStrings(popList(literalCount))); 154 push(ast.adjacentStrings(popList(literalCount)));
150 } 155 }
151 156
152 void endArguments(int count, Token beginToken, Token endToken) { 157 void endArguments(int count, Token beginToken, Token endToken) {
153 debugEvent("Arguments"); 158 debugEvent("Arguments");
154 List expressions = popList(count); 159 List expressions = popList(count);
155 ArgumentList arguments = ast.argumentList( 160 ArgumentList arguments = ast.argumentList(
156 toAnalyzerToken(beginToken), expressions, toAnalyzerToken(endToken)); 161 toAnalyzerToken(beginToken), expressions, toAnalyzerToken(endToken));
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 846
842 @override 847 @override
843 void endTopLevelDeclaration(Token token) { 848 void endTopLevelDeclaration(Token token) {
844 debugEvent("TopLevelDeclaration"); 849 debugEvent("TopLevelDeclaration");
845 } 850 }
846 851
847 @override 852 @override
848 void endCompilationUnit(int count, Token token) { 853 void endCompilationUnit(int count, Token token) {
849 debugEvent("CompilationUnit"); 854 debugEvent("CompilationUnit");
850 analyzer.Token beginToken = null; // TODO(paulberry) 855 analyzer.Token beginToken = null; // TODO(paulberry)
851 ScriptTag scriptTag = null; // TODO(paulberry) 856 ScriptTag scriptTag = null;
852 var directives = <Directive>[]; 857 var directives = <Directive>[];
853 var declarations = <CompilationUnitMember>[]; 858 var declarations = <CompilationUnitMember>[];
854 analyzer.Token endToken = null; // TODO(paulberry) 859 analyzer.Token endToken = null; // TODO(paulberry)
855 List<Object> elements = popList(count); 860 List<Object> elements = popList(count);
856 if (elements != null) { 861 if (elements != null) {
857 for (AstNode node in elements) { 862 for (AstNode node in elements) {
858 if (node is Directive) { 863 if (node is ScriptTag) {
864 scriptTag = node;
865 } else if (node is Directive) {
859 directives.add(node); 866 directives.add(node);
860 } else if (node is CompilationUnitMember) { 867 } else if (node is CompilationUnitMember) {
861 declarations.add(node); 868 declarations.add(node);
862 } else { 869 } else {
863 internalError( 870 internalError(
864 'Unrecognized compilation unit member: ${node.runtimeType}'); 871 'Unrecognized compilation unit member: ${node.runtimeType}');
865 } 872 }
866 } 873 }
867 } 874 }
868 push(ast.compilationUnit( 875 push(ast.compilationUnit(
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 } else if (identical('static', s)) { 1490 } else if (identical('static', s)) {
1484 staticKeyword = token; 1491 staticKeyword = token;
1485 } else if (identical('var', s)) { 1492 } else if (identical('var', s)) {
1486 finalConstOrVarKeyword = token; 1493 finalConstOrVarKeyword = token;
1487 } else { 1494 } else {
1488 internalError('Unhandled modifier: $s'); 1495 internalError('Unhandled modifier: $s');
1489 } 1496 }
1490 } 1497 }
1491 } 1498 }
1492 } 1499 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | pkg/front_end/lib/src/fasta/analyzer/token_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698