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

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

Issue 2747083005: Parse for-in statements 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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 TypeAnnotation returnType = pop(); 647 TypeAnnotation returnType = pop();
648 push(ast.genericFunctionType(returnType, toAnalyzerToken(functionToken), 648 push(ast.genericFunctionType(returnType, toAnalyzerToken(functionToken),
649 typeParameters, parameters)); 649 typeParameters, parameters));
650 } 650 }
651 651
652 void handleFormalParameterWithoutValue(Token token) { 652 void handleFormalParameterWithoutValue(Token token) {
653 debugEvent("FormalParameterWithoutValue"); 653 debugEvent("FormalParameterWithoutValue");
654 push(NullValue.ParameterDefaultValue); 654 push(NullValue.ParameterDefaultValue);
655 } 655 }
656 656
657 @override
658 void endForInExpression(Token token) {
659 debugEvent("ForInExpression");
660 }
661
662 @override
663 void endForIn(Token awaitToken, Token forToken, Token leftParenthesis,
664 Token inKeyword, Token rightParenthesis, Token endToken) {
665 debugEvent("ForInExpression");
666 Statement body = pop();
667 Expression iterator = pop();
668 Object variableOrDeclaration = pop();
669 pop(); // local scope
670 pop(); // continue target
671 pop(); // break target
672 if (variableOrDeclaration is SimpleIdentifier) {
673 push(ast.forEachStatementWithReference(
674 toAnalyzerToken(awaitToken),
675 toAnalyzerToken(forToken),
676 toAnalyzerToken(leftParenthesis),
677 variableOrDeclaration,
678 toAnalyzerToken(inKeyword),
679 iterator,
680 toAnalyzerToken(rightParenthesis),
681 body));
682 } else {
683 var statement = variableOrDeclaration as VariableDeclarationStatement;
684 VariableDeclarationList variableList = statement.variables;
685 push(ast.forEachStatementWithDeclaration(
686 toAnalyzerToken(awaitToken),
687 toAnalyzerToken(forToken),
688 toAnalyzerToken(leftParenthesis),
689 ast.declaredIdentifier(
690 variableList.documentationComment,
691 variableList.metadata,
692 variableList.keyword,
693 variableList.type,
694 variableList.variables.single.name),
695 toAnalyzerToken(inKeyword),
696 iterator,
697 toAnalyzerToken(rightParenthesis),
698 body));
699 }
700 }
701
657 void endFormalParameter( 702 void endFormalParameter(
658 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { 703 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) {
659 debugEvent("FormalParameter"); 704 debugEvent("FormalParameter");
660 _ParameterDefaultValue defaultValue = pop(); 705 _ParameterDefaultValue defaultValue = pop();
661 706
662 AstNode nameOrFunctionTypedParameter = pop(); 707 AstNode nameOrFunctionTypedParameter = pop();
663 708
664 FormalParameter node; 709 FormalParameter node;
665 SimpleIdentifier name; 710 SimpleIdentifier name;
666 if (nameOrFunctionTypedParameter is FormalParameter) { 711 if (nameOrFunctionTypedParameter is FormalParameter) {
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 } else if (identical('static', s)) { 1691 } else if (identical('static', s)) {
1647 staticKeyword = token; 1692 staticKeyword = token;
1648 } else if (identical('var', s)) { 1693 } else if (identical('var', s)) {
1649 finalConstOrVarKeyword = token; 1694 finalConstOrVarKeyword = token;
1650 } else { 1695 } else {
1651 internalError('Unhandled modifier: $s'); 1696 internalError('Unhandled modifier: $s');
1652 } 1697 }
1653 } 1698 }
1654 } 1699 }
1655 } 1700 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/parser/node_listener.dart ('k') | pkg/front_end/lib/src/fasta/kernel/body_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698