| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.parser; |
| 6 |
| 5 import 'dart:collection'; | 7 import 'dart:collection'; |
| 6 import "dart:math" as math; | 8 import "dart:math" as math; |
| 7 | 9 |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 11 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 12 import 'package:analyzer/dart/ast/token.dart'; |
| 11 import 'package:analyzer/error/error.dart'; | 13 import 'package:analyzer/error/error.dart'; |
| 12 import 'package:analyzer/error/listener.dart'; | 14 import 'package:analyzer/error/listener.dart'; |
| 13 import 'package:analyzer/src/dart/ast/ast.dart'; | 15 import 'package:analyzer/src/dart/ast/ast.dart'; |
| 14 import 'package:analyzer/src/dart/ast/token.dart'; | 16 import 'package:analyzer/src/dart/ast/token.dart'; |
| 15 import 'package:analyzer/src/dart/error/syntactic_errors.dart'; | 17 import 'package:analyzer/src/dart/error/syntactic_errors.dart'; |
| 16 import 'package:analyzer/src/dart/scanner/reader.dart'; | 18 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 17 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 19 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 18 import 'package:analyzer/src/error/codes.dart'; | 20 import 'package:analyzer/src/error/codes.dart'; |
| 21 import 'package:analyzer/src/fasta/ast_builder.dart'; |
| 22 import 'package:analyzer/src/fasta/element_store.dart'; |
| 19 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; | 23 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; |
| 20 import 'package:analyzer/src/generated/java_core.dart'; | 24 import 'package:analyzer/src/generated/java_core.dart'; |
| 21 import 'package:analyzer/src/generated/java_engine.dart'; | 25 import 'package:analyzer/src/generated/java_engine.dart'; |
| 22 import 'package:analyzer/src/generated/source.dart'; | 26 import 'package:analyzer/src/generated/source.dart'; |
| 23 import 'package:analyzer/src/generated/utilities_dart.dart'; | 27 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 28 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'; |
| 29 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart'; |
| 30 import 'package:front_end/src/fasta/parser/parser.dart' as fasta; |
| 24 | 31 |
| 25 export 'package:analyzer/src/dart/ast/utilities.dart' show ResolutionCopier; | 32 export 'package:analyzer/src/dart/ast/utilities.dart' show ResolutionCopier; |
| 26 export 'package:analyzer/src/dart/error/syntactic_errors.dart'; | 33 export 'package:analyzer/src/dart/error/syntactic_errors.dart'; |
| 27 | 34 |
| 35 part 'parser_fasta.dart'; |
| 36 |
| 28 /** | 37 /** |
| 29 * A simple data-holder for a method that needs to return multiple values. | 38 * A simple data-holder for a method that needs to return multiple values. |
| 30 */ | 39 */ |
| 31 class CommentAndMetadata { | 40 class CommentAndMetadata { |
| 32 /** | 41 /** |
| 33 * The documentation comment that was parsed, or `null` if none was given. | 42 * The documentation comment that was parsed, or `null` if none was given. |
| 34 */ | 43 */ |
| 35 final Comment comment; | 44 final Comment comment; |
| 36 | 45 |
| 37 /** | 46 /** |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 @deprecated | 263 @deprecated |
| 255 bool parseGenericMethods = false; | 264 bool parseGenericMethods = false; |
| 256 | 265 |
| 257 /** | 266 /** |
| 258 * A flag indicating whether to parse generic method comments, of the form | 267 * A flag indicating whether to parse generic method comments, of the form |
| 259 * `/*=T*/` and `/*<T>*/`. | 268 * `/*=T*/` and `/*<T>*/`. |
| 260 */ | 269 */ |
| 261 bool parseGenericMethodComments = false; | 270 bool parseGenericMethodComments = false; |
| 262 | 271 |
| 263 /** | 272 /** |
| 273 * A flag indicating whether the analyzer [Parser] factory method |
| 274 * will return a fasta based parser or an analyzer based parser. |
| 275 */ |
| 276 static bool useFasta = const bool.fromEnvironment("useFastaParser"); |
| 277 |
| 278 /** |
| 264 * Initialize a newly created parser to parse tokens in the given [_source] | 279 * Initialize a newly created parser to parse tokens in the given [_source] |
| 265 * and to report any errors that are found to the given [_errorListener]. | 280 * and to report any errors that are found to the given [_errorListener]. |
| 266 */ | 281 */ |
| 267 Parser(this._source, this._errorListener); | 282 factory Parser(Source source, AnalysisErrorListener errorListener, |
| 283 {bool useFasta}) { |
| 284 if (useFasta ?? Parser.useFasta) { |
| 285 return new _Parser2(source, errorListener); |
| 286 } else { |
| 287 return new Parser._(source, errorListener); |
| 288 } |
| 289 } |
| 290 |
| 291 Parser._(this._source, this._errorListener); |
| 268 | 292 |
| 269 /** | 293 /** |
| 270 * Return the current token. | 294 * Return the current token. |
| 271 */ | 295 */ |
| 272 Token get currentToken => _currentToken; | 296 Token get currentToken => _currentToken; |
| 273 | 297 |
| 274 /** | 298 /** |
| 275 * Set the token with which the parse is to begin to the given [token]. | 299 * Set the token with which the parse is to begin to the given [token]. |
| 276 */ | 300 */ |
| 277 void set currentToken(Token token) { | 301 void set currentToken(Token token) { |
| (...skipping 8324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8602 } | 8626 } |
| 8603 } | 8627 } |
| 8604 } | 8628 } |
| 8605 | 8629 |
| 8606 /** | 8630 /** |
| 8607 * Instances of this class are thrown when the parser detects that AST has | 8631 * Instances of this class are thrown when the parser detects that AST has |
| 8608 * too many nested expressions to be parsed safely and avoid possibility of | 8632 * too many nested expressions to be parsed safely and avoid possibility of |
| 8609 * [StackOverflowError] in the parser or during later analysis. | 8633 * [StackOverflowError] in the parser or during later analysis. |
| 8610 */ | 8634 */ |
| 8611 class _TooDeepTreeError {} | 8635 class _TooDeepTreeError {} |
| OLD | NEW |