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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 2981343002: improve fasta closing brace recovery (Closed)
Patch Set: rebase Created 3 years, 5 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 {}
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698