OLD | NEW |
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 Expression expression = pop(); | 231 Expression expression = pop(); |
232 CascadeExpression receiver = pop(); | 232 CascadeExpression receiver = pop(); |
233 pop(); // Token. | 233 pop(); // Token. |
234 receiver.cascadeSections.add(expression); | 234 receiver.cascadeSections.add(expression); |
235 push(receiver); | 235 push(receiver); |
236 } | 236 } |
237 | 237 |
238 void handleBinaryExpression(Token token) { | 238 void handleBinaryExpression(Token token) { |
239 debugEvent("BinaryExpression"); | 239 debugEvent("BinaryExpression"); |
240 if (identical(".", token.stringValue) || | 240 if (identical(".", token.stringValue) || |
| 241 identical("?.", token.stringValue) || |
241 identical("..", token.stringValue)) { | 242 identical("..", token.stringValue)) { |
242 doDotExpression(token); | 243 doDotExpression(token); |
243 } else { | 244 } else { |
244 Expression right = pop(); | 245 Expression right = pop(); |
245 Expression left = pop(); | 246 Expression left = pop(); |
246 push(ast.binaryExpression(left, toAnalyzerToken(token), right)); | 247 push(ast.binaryExpression(left, toAnalyzerToken(token), right)); |
247 } | 248 } |
248 } | 249 } |
249 | 250 |
250 void doDotExpression(Token token) { | 251 void doDotExpression(Token token) { |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 } else { | 1168 } else { |
1168 // TODO(scheglov): Report error. | 1169 // TODO(scheglov): Report error. |
1169 internalError("Invalid modifier ($value). Report an error."); | 1170 internalError("Invalid modifier ($value). Report an error."); |
1170 } | 1171 } |
1171 } | 1172 } |
1172 | 1173 |
1173 List<Annotation> metadata = pop(); | 1174 List<Annotation> metadata = pop(); |
1174 // TODO(paulberry): capture doc comments. See dartbug.com/28851. | 1175 // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
1175 Comment comment = null; | 1176 Comment comment = null; |
1176 Token period; | 1177 Token period; |
1177 void unnamedConstructor(SimpleIdentifier returnType, SimpleIdentifier name)
{ | 1178 void unnamedConstructor( |
| 1179 SimpleIdentifier returnType, SimpleIdentifier name) { |
1178 push(ast.constructorDeclaration( | 1180 push(ast.constructorDeclaration( |
1179 comment, | 1181 comment, |
1180 metadata, | 1182 metadata, |
1181 toAnalyzerToken(externalKeyword), | 1183 toAnalyzerToken(externalKeyword), |
1182 toAnalyzerToken(constKeyword), | 1184 toAnalyzerToken(constKeyword), |
1183 toAnalyzerToken(factoryKeyword), | 1185 toAnalyzerToken(factoryKeyword), |
1184 returnType, | 1186 returnType, |
1185 toAnalyzerToken(period), | 1187 toAnalyzerToken(period), |
1186 name, | 1188 name, |
1187 parameters, | 1189 parameters, |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 } | 1399 } |
1398 | 1400 |
1399 /// Data structure placed on the stack to represent the keyword "operator" | 1401 /// Data structure placed on the stack to represent the keyword "operator" |
1400 /// followed by a token. | 1402 /// followed by a token. |
1401 class _OperatorName { | 1403 class _OperatorName { |
1402 final Token operatorKeyword; | 1404 final Token operatorKeyword; |
1403 final SimpleIdentifier name; | 1405 final SimpleIdentifier name; |
1404 | 1406 |
1405 _OperatorName(this.operatorKeyword, this.name); | 1407 _OperatorName(this.operatorKeyword, this.name); |
1406 } | 1408 } |
OLD | NEW |