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

Issue 2981343002: improve fasta closing brace recovery (Closed)

Created:
3 years, 5 months ago by danrubel
Modified:
3 years, 4 months ago
Reviewers:
Paul Berry, ahe
CC:
reviews_dartlang.org, dart-fe-team+reviews_google.com
Target Ref:
refs/heads/master
Visibility:
Public.

Description

improve fasta closing brace recovery Currently, fasta synthetically closes open braces until it finds a match for the current closing brace. This works most of the time, but provides less than optimal recovery in some common cases. For example, given the following class { foo()){print(a);} var a = 'hello'; } the current brace recovery method fails to find any match for the second closing parenthesis and synthetically closes the class causing the rest of the file to be parsed as outside the class. With this CL, fasta still synthetically closes open braces when it finds a match for the current closing brace, but if there is no match, then it just skips over the extra closer and continues. This approach dramatically improves recovery in many cases where there is an extra closing parenthesis or extra closing square bracket. In the example above, fasta parses everything after the second closing parenthesis inside the class. R=paulberry@google.com Committed: https://github.com/dart-lang/sdk/commit/0b93c279e7a2d81ef9945e1d2bfb976638211a8e

Patch Set 1 #

Patch Set 2 : rebase #

Total comments: 5

Patch Set 3 : fix while loop performance #

Patch Set 4 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+109 lines, -38 lines) Patch
M pkg/analyzer/lib/src/generated/parser.dart View 2 chunks +12 lines, -0 lines 0 comments Download
M pkg/analyzer/test/generated/parser_test.dart View 1 3 chunks +15 lines, -9 lines 0 comments Download
M pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart View 1 2 2 chunks +46 lines, -14 lines 0 comments Download
M pkg/front_end/test/scanner_test.dart View 2 chunks +26 lines, -7 lines 0 comments Download
M tests/compiler/dart2js/error_token_test.dart View 3 chunks +10 lines, -8 lines 0 comments Download

Messages

Total messages: 7 (2 generated)
danrubel
3 years, 5 months ago (2017-07-20 02:30:30 UTC) #2
Paul Berry
lgtm assuming the while loop is changed https://codereview.chromium.org/2981343002/diff/20001/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart File pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart (right): https://codereview.chromium.org/2981343002/diff/20001/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart#newcode148 pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart:148: appendPrecedenceToken(type); Not ...
3 years, 5 months ago (2017-07-20 16:01:02 UTC) #3
danrubel
https://codereview.chromium.org/2981343002/diff/20001/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart File pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart (right): https://codereview.chromium.org/2981343002/diff/20001/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart#newcode148 pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart:148: appendPrecedenceToken(type); On 2017/07/20 16:01:02, Paul Berry wrote: > Not ...
3 years, 5 months ago (2017-07-21 14:23:51 UTC) #4
Paul Berry
https://codereview.chromium.org/2981343002/diff/20001/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart File pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart (right): https://codereview.chromium.org/2981343002/diff/20001/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart#newcode148 pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart:148: appendPrecedenceToken(type); On 2017/07/21 14:23:50, danrubel wrote: > On 2017/07/20 ...
3 years, 5 months ago (2017-07-21 17:13:45 UTC) #5
danrubel
3 years, 4 months ago (2017-07-26 14:37:28 UTC) #7
Message was sent while issue was closed.
Committed patchset #4 (id:60001) manually as
0b93c279e7a2d81ef9945e1d2bfb976638211a8e (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698