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

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

Issue 2752543005: Parse try-catch statements with Fasta. (Closed)
Patch Set: Update the status file. 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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 toAnalyzerToken(beginToken), 778 toAnalyzerToken(beginToken),
779 parameters, 779 parameters,
780 toAnalyzerToken(leftDelimiter), 780 toAnalyzerToken(leftDelimiter),
781 toAnalyzerToken(rightDelimiter), 781 toAnalyzerToken(rightDelimiter),
782 toAnalyzerToken(endToken))); 782 toAnalyzerToken(endToken)));
783 } 783 }
784 784
785 void handleCatchBlock(Token onKeyword, Token catchKeyword) { 785 void handleCatchBlock(Token onKeyword, Token catchKeyword) {
786 debugEvent("CatchBlock"); 786 debugEvent("CatchBlock");
787 Block body = pop(); 787 Block body = pop();
788 FormalParameterList catchParameters = popIfNotNull(catchKeyword); 788 FormalParameterList catchParameterList = popIfNotNull(catchKeyword);
789 if (catchKeyword != null) {
790 exitLocalScope();
791 }
792 TypeAnnotation type = popIfNotNull(onKeyword); 789 TypeAnnotation type = popIfNotNull(onKeyword);
793 SimpleIdentifier exception; 790 SimpleIdentifier exception;
794 SimpleIdentifier stackTrace; 791 SimpleIdentifier stackTrace;
795 if (catchParameters != null) { 792 if (catchParameterList != null) {
793 List<FormalParameter> catchParameters = catchParameterList.parameters;
796 if (catchParameters.length > 0) { 794 if (catchParameters.length > 0) {
797 exception = catchParameters.parameters[0].identifier; 795 exception = catchParameters[0].identifier;
798 } 796 }
799 if (catchParameters.length > 1) { 797 if (catchParameters.length > 1) {
800 stackTrace = catchParameters.parameters[1].identifier; 798 stackTrace = catchParameters[1].identifier;
801 } 799 }
802 } 800 }
803 BeginGroupToken leftParenthesis = catchKeyword.next;
804 push(ast.catchClause( 801 push(ast.catchClause(
805 toAnalyzerToken(onKeyword), 802 toAnalyzerToken(onKeyword),
806 type, 803 type,
807 toAnalyzerToken(catchKeyword), 804 toAnalyzerToken(catchKeyword),
808 toAnalyzerToken(leftParenthesis), 805 catchParameterList?.leftParenthesis,
809 exception, 806 exception,
810 null, 807 null,
811 stackTrace, 808 stackTrace,
812 toAnalyzerToken(leftParenthesis.endGroup), 809 catchParameterList?.rightParenthesis,
813 body)); 810 body));
814 } 811 }
815 812
813 @override
814 void handleFinallyBlock(Token finallyKeyword) {
815 debugEvent("FinallyBlock");
816 // The finally block is popped in "endTryStatement".
817 }
818
816 void endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) { 819 void endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) {
817 Block finallyBlock = popIfNotNull(finallyKeyword); 820 Block finallyBlock = popIfNotNull(finallyKeyword);
818 List<CatchClause> catchClauses = popList(catchCount); 821 List<CatchClause> catchClauses = popList(catchCount);
819 Block body = pop(); 822 Block body = pop();
820 push(ast.tryStatement(toAnalyzerToken(tryKeyword), body, catchClauses, 823 push(ast.tryStatement(toAnalyzerToken(tryKeyword), body, catchClauses,
821 toAnalyzerToken(finallyKeyword), finallyBlock)); 824 toAnalyzerToken(finallyKeyword), finallyBlock));
822 } 825 }
823 826
824 void handleNoExpression(Token token) { 827 void handleNoExpression(Token token) {
825 debugEvent("NoExpression"); 828 debugEvent("NoExpression");
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 } else if (identical('static', s)) { 1646 } else if (identical('static', s)) {
1644 staticKeyword = token; 1647 staticKeyword = token;
1645 } else if (identical('var', s)) { 1648 } else if (identical('var', s)) {
1646 finalConstOrVarKeyword = token; 1649 finalConstOrVarKeyword = token;
1647 } else { 1650 } else {
1648 internalError('Unhandled modifier: $s'); 1651 internalError('Unhandled modifier: $s');
1649 } 1652 }
1650 } 1653 }
1651 } 1654 }
1652 } 1655 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | pkg/front_end/test/fasta/kompile.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698