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

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

Issue 2899043006: cleanup fasta token classes (Closed)
Patch Set: Created 3 years, 6 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;
11 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; 11 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
12 import 'package:analyzer/dart/element/element.dart' show Element; 12 import 'package:analyzer/dart/element/element.dart' show Element;
13 import 'package:front_end/src/fasta/parser/parser.dart' 13 import 'package:front_end/src/fasta/parser/parser.dart'
14 show FormalParameterType, MemberKind, Parser; 14 show FormalParameterType, MemberKind, Parser;
15 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; 15 import 'package:front_end/src/fasta/scanner/string_scanner.dart';
16 import 'package:front_end/src/fasta/scanner/token.dart' 16 import 'package:front_end/src/fasta/scanner/token.dart' show CommentToken;
17 show BeginGroupToken, CommentToken;
18 import 'package:front_end/src/scanner/token.dart' as analyzer; 17 import 'package:front_end/src/scanner/token.dart' as analyzer;
19 18
20 import 'package:front_end/src/fasta/errors.dart' show internalError; 19 import 'package:front_end/src/fasta/errors.dart' show internalError;
21 import 'package:front_end/src/fasta/fasta_codes.dart' 20 import 'package:front_end/src/fasta/fasta_codes.dart'
22 show FastaMessage, codeExpectedExpression, codeExpectedFunctionBody; 21 show FastaMessage, codeExpectedExpression, codeExpectedFunctionBody;
23 import 'package:front_end/src/fasta/kernel/kernel_builder.dart' 22 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'
24 show Builder, KernelLibraryBuilder, ProcedureBuilder, Scope; 23 show Builder, KernelLibraryBuilder, ProcedureBuilder, Scope;
25 import 'package:front_end/src/fasta/parser/identifier_context.dart' 24 import 'package:front_end/src/fasta/parser/identifier_context.dart'
26 show IdentifierContext; 25 show IdentifierContext;
27 import 'package:front_end/src/fasta/quote.dart'; 26 import 'package:front_end/src/fasta/quote.dart';
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 token, constructorName, arguments.argumentList)); 116 token, constructorName, arguments.argumentList));
118 } 117 }
119 118
120 @override 119 @override
121 void endNewExpression(Token token) { 120 void endNewExpression(Token token) {
122 debugEvent("NewExpression"); 121 debugEvent("NewExpression");
123 _handleInstanceCreation(token); 122 _handleInstanceCreation(token);
124 } 123 }
125 124
126 @override 125 @override
127 void handleParenthesizedExpression(BeginGroupToken token) { 126 void handleParenthesizedExpression(analyzer.BeginToken token) {
128 debugEvent("ParenthesizedExpression"); 127 debugEvent("ParenthesizedExpression");
129 Expression expression = pop(); 128 Expression expression = pop();
130 push(ast.parenthesizedExpression(token, expression, token.endGroup)); 129 push(ast.parenthesizedExpression(token, expression, token.endGroup));
131 } 130 }
132 131
133 void handleStringPart(Token token) { 132 void handleStringPart(Token token) {
134 debugEvent("StringPart"); 133 debugEvent("StringPart");
135 push(token); 134 push(token);
136 } 135 }
137 136
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 bool hasExpression, Token beginToken, Token endToken) { 389 bool hasExpression, Token beginToken, Token endToken) {
391 debugEvent("ReturnStatement"); 390 debugEvent("ReturnStatement");
392 Expression expression = hasExpression ? pop() : null; 391 Expression expression = hasExpression ? pop() : null;
393 push(ast.returnStatement(beginToken, expression, endToken)); 392 push(ast.returnStatement(beginToken, expression, endToken));
394 } 393 }
395 394
396 void endIfStatement(Token ifToken, Token elseToken) { 395 void endIfStatement(Token ifToken, Token elseToken) {
397 Statement elsePart = popIfNotNull(elseToken); 396 Statement elsePart = popIfNotNull(elseToken);
398 Statement thenPart = pop(); 397 Statement thenPart = pop();
399 Expression condition = pop(); 398 Expression condition = pop();
400 BeginGroupToken leftParenthesis = ifToken.next; 399 analyzer.BeginToken leftParenthesis = ifToken.next;
401 push(ast.ifStatement(ifToken, ifToken.next, condition, 400 push(ast.ifStatement(ifToken, ifToken.next, condition,
402 leftParenthesis.endGroup, thenPart, elseToken, elsePart)); 401 leftParenthesis.endGroup, thenPart, elseToken, elsePart));
403 } 402 }
404 403
405 void handleNoInitializers() { 404 void handleNoInitializers() {
406 debugEvent("NoInitializers"); 405 debugEvent("NoInitializers");
407 push(NullValue.ConstructorInitializerSeparator); 406 push(NullValue.ConstructorInitializerSeparator);
408 push(NullValue.ConstructorInitializers); 407 push(NullValue.ConstructorInitializers);
409 } 408 }
410 409
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 void endForStatement(Token forKeyword, Token leftSeparator, 555 void endForStatement(Token forKeyword, Token leftSeparator,
557 int updateExpressionCount, Token endToken) { 556 int updateExpressionCount, Token endToken) {
558 debugEvent("ForStatement"); 557 debugEvent("ForStatement");
559 Statement body = pop(); 558 Statement body = pop();
560 List<Expression> updates = popList(updateExpressionCount); 559 List<Expression> updates = popList(updateExpressionCount);
561 Statement conditionStatement = pop(); 560 Statement conditionStatement = pop();
562 Object initializerPart = pop(); 561 Object initializerPart = pop();
563 exitLocalScope(); 562 exitLocalScope();
564 exitContinueTarget(); 563 exitContinueTarget();
565 exitBreakTarget(); 564 exitBreakTarget();
566 BeginGroupToken leftParenthesis = forKeyword.next; 565 analyzer.BeginToken leftParenthesis = forKeyword.next;
567 566
568 VariableDeclarationList variableList; 567 VariableDeclarationList variableList;
569 Expression initializer; 568 Expression initializer;
570 if (initializerPart is VariableDeclarationStatement) { 569 if (initializerPart is VariableDeclarationStatement) {
571 variableList = initializerPart.variables; 570 variableList = initializerPart.variables;
572 } else { 571 } else {
573 initializer = initializerPart as Expression; 572 initializer = initializerPart as Expression;
574 } 573 }
575 574
576 Expression condition; 575 Expression condition;
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 push(ast.genericTypeAlias(comment, metadata, typedefKeyword, name, 1731 push(ast.genericTypeAlias(comment, metadata, typedefKeyword, name,
1733 templateParameters, equals, type, endToken)); 1732 templateParameters, equals, type, endToken));
1734 } 1733 }
1735 } 1734 }
1736 1735
1737 @override 1736 @override
1738 void endEnum(Token enumKeyword, Token endBrace, int count) { 1737 void endEnum(Token enumKeyword, Token endBrace, int count) {
1739 debugEvent("Enum"); 1738 debugEvent("Enum");
1740 List<EnumConstantDeclaration> constants = popList(count); 1739 List<EnumConstantDeclaration> constants = popList(count);
1741 // TODO(paulberry,ahe): the parser should pass in the openBrace token. 1740 // TODO(paulberry,ahe): the parser should pass in the openBrace token.
1742 var openBrace = enumKeyword.next.next as BeginGroupToken; 1741 var openBrace = enumKeyword.next.next as analyzer.BeginToken;
1743 // TODO(paulberry): what if the '}' is missing and the parser has performed 1742 // TODO(paulberry): what if the '}' is missing and the parser has performed
1744 // error recovery? 1743 // error recovery?
1745 Token closeBrace = openBrace.endGroup; 1744 Token closeBrace = openBrace.endGroup;
1746 SimpleIdentifier name = pop(); 1745 SimpleIdentifier name = pop();
1747 List<Annotation> metadata = pop(); 1746 List<Annotation> metadata = pop();
1748 Comment comment = pop(); 1747 Comment comment = pop();
1749 push(ast.enumDeclaration(comment, metadata, enumKeyword, name, openBrace, 1748 push(ast.enumDeclaration(comment, metadata, enumKeyword, name, openBrace,
1750 constants, closeBrace)); 1749 constants, closeBrace));
1751 } 1750 }
1752 1751
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 } else if (identical('var', s)) { 2015 } else if (identical('var', s)) {
2017 finalConstOrVarKeyword = token; 2016 finalConstOrVarKeyword = token;
2018 } else if (identical('covariant', s)) { 2017 } else if (identical('covariant', s)) {
2019 covariantKeyword = token; 2018 covariantKeyword = token;
2020 } else { 2019 } else {
2021 internalError('Unhandled modifier: $s'); 2020 internalError('Unhandled modifier: $s');
2022 } 2021 }
2023 } 2022 }
2024 } 2023 }
2025 } 2024 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | pkg/analyzer/lib/src/fasta/token_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698