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; | 5 library analyzer.parser; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import "dart:math" as math; | 8 import "dart:math" as math; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 6893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6904 | 6904 |
6905 if (type == TokenType.CLOSE_SQUARE_BRACKET) { | 6905 if (type == TokenType.CLOSE_SQUARE_BRACKET) { |
6906 rightSquareBracket = getAndAdvance(); | 6906 rightSquareBracket = getAndAdvance(); |
6907 if (leftSquareBracket == null) { | 6907 if (leftSquareBracket == null) { |
6908 if (leftCurlyBracket != null) { | 6908 if (leftCurlyBracket != null) { |
6909 _reportErrorForCurrentToken( | 6909 _reportErrorForCurrentToken( |
6910 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, | 6910 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, |
6911 ['}', ']']); | 6911 ['}', ']']); |
6912 rightCurlyBracket = rightSquareBracket; | 6912 rightCurlyBracket = rightSquareBracket; |
6913 rightSquareBracket = null; | 6913 rightSquareBracket = null; |
| 6914 // Skip over synthetic closer inserted by fasta |
| 6915 // since we've already reported an error |
| 6916 if (_currentToken.type == TokenType.CLOSE_CURLY_BRACKET && |
| 6917 _currentToken.isSynthetic) { |
| 6918 _advance(); |
| 6919 } |
6914 } else { | 6920 } else { |
6915 _reportErrorForCurrentToken( | 6921 _reportErrorForCurrentToken( |
6916 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, | 6922 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, |
6917 ["["]); | 6923 ["["]); |
6918 } | 6924 } |
6919 } | 6925 } |
6920 kind = ParameterKind.REQUIRED; | 6926 kind = ParameterKind.REQUIRED; |
6921 } else if (type == TokenType.CLOSE_CURLY_BRACKET) { | 6927 } else if (type == TokenType.CLOSE_CURLY_BRACKET) { |
6922 rightCurlyBracket = getAndAdvance(); | 6928 rightCurlyBracket = getAndAdvance(); |
6923 if (leftCurlyBracket == null) { | 6929 if (leftCurlyBracket == null) { |
6924 if (leftSquareBracket != null) { | 6930 if (leftSquareBracket != null) { |
6925 _reportErrorForCurrentToken( | 6931 _reportErrorForCurrentToken( |
6926 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, | 6932 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, |
6927 [']', '}']); | 6933 [']', '}']); |
6928 rightSquareBracket = rightCurlyBracket; | 6934 rightSquareBracket = rightCurlyBracket; |
6929 rightCurlyBracket = null; | 6935 rightCurlyBracket = null; |
| 6936 // Skip over synthetic closer inserted by fasta |
| 6937 // since we've already reported an error |
| 6938 if (_currentToken.type == TokenType.CLOSE_SQUARE_BRACKET && |
| 6939 _currentToken.isSynthetic) { |
| 6940 _advance(); |
| 6941 } |
6930 } else { | 6942 } else { |
6931 _reportErrorForCurrentToken( | 6943 _reportErrorForCurrentToken( |
6932 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, | 6944 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, |
6933 ["{"]); | 6945 ["{"]); |
6934 } | 6946 } |
6935 } | 6947 } |
6936 kind = ParameterKind.REQUIRED; | 6948 kind = ParameterKind.REQUIRED; |
6937 } | 6949 } |
6938 } while (!_matches(TokenType.CLOSE_PAREN) && | 6950 } while (!_matches(TokenType.CLOSE_PAREN) && |
6939 !identical(initialToken, _currentToken)); | 6951 !identical(initialToken, _currentToken)); |
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8649 } | 8661 } |
8650 } | 8662 } |
8651 } | 8663 } |
8652 | 8664 |
8653 /** | 8665 /** |
8654 * Instances of this class are thrown when the parser detects that AST has | 8666 * Instances of this class are thrown when the parser detects that AST has |
8655 * too many nested expressions to be parsed safely and avoid possibility of | 8667 * too many nested expressions to be parsed safely and avoid possibility of |
8656 * [StackOverflowError] in the parser or during later analysis. | 8668 * [StackOverflowError] in the parser or during later analysis. |
8657 */ | 8669 */ |
8658 class _TooDeepTreeError {} | 8670 class _TooDeepTreeError {} |
OLD | NEW |