Commit Graph

51 Commits

Author SHA1 Message Date
Johnni Winther 34fb48bb8a [kernel,front_end] Migrate first wave of pkg/kernel and pkg/front_end
Migrates libraries dependent only on already migrated libraries.

Change-Id: I0e85ee8dbc2afce031b92e0009e71c206a55af28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179502
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-01-18 15:40:21 +00:00
Paul Berry 3ca37fb66e Re-apply some recent parser fixes.
My recent revert (275b922ee8) mistakenly
reverted too much (I incorrectly attributed the angular failure to
1f9b5c1996 when it was actually due to
96df1f9e6c).  Reapply the commits that
are ok.

This re-applies commit 1f9b5c1996.
This re-applies commit c40b24da48.

Change-Id: I4d64b1511b92d87197a5e939903a31e01f0b2e70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147920
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-13 16:00:01 +00:00
Paul Berry 275b922ee8 Revert recent parser fixes
Commit 1f9b5c1996 causes tests to fail
in angular when rolled into internal sources; the other two commits
need to be reverted as well to avoid merge conflicts.

This reverts commit 1f9b5c1996.
This reverts commit c40b24da48.
This reverts commit 96df1f9e6c.

Change-Id: Ic4e55181ef60e825ce4409a9a9528ecbf19c39c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147822
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-12 22:02:09 +00:00
Jens Johansen 96df1f9e6c [parser] Add ErrorToken for ignored (unmatched) end parenthesis, brackets etc
Change-Id: Idb57295700988d71321743af9782134b02562311
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146240
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-05-11 14:46:47 +00:00
Jens Johansen 1f9b5c1996 [parser] Recovery of unbalanced parenthesis, brackets etc.
Bug: https://github.com/dart-lang/sdk/issues/41000

Change-Id: I8d1d8ff5d3f832f9b6b5e5880b59a485a7ff9b96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146224
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-05-07 10:04:08 +00:00
Johnni Winther 00c2962db8 [cfe+analyzer] Move messages, scanner and parser to package:_fe_analyzer_shared
Change-Id: I4fa87aee65f30a9868a6cf8f0342591869ece7ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123663
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-11-01 09:37:57 +00:00
Paul Berry 5b4612bc68 Move front_end/lib/src/base/errors.dart into _fe_analyzer_shared package.
Change-Id: I9369e8dbf7b5d6fff9ad2a74346871b3e274e8ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123640
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2019-10-31 13:05:53 +00:00
Kallen Tu 89220fd812 Variance Parsing and Syntax Support
With the experiment flag on, will properly parse the `in`/`out`/`inout`
keywords. Without it, will issue an error regarding the flag. First CL
for parsing, syntax support, no AST work yet.

Keywords only parse correctly for classes and mixins.
See test `variance_disabled_syntax_test.dart`.


Change-Id: I37d765804fa0752512abf52fa44456a173087ef0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117929
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
2019-09-24 17:21:39 +00:00
Kallen Tu b699852e6d Add 'out'/'inout' keywords for variance.
Under the `variance` flag, `out` and `inout` will be treated as keywords.

Change-Id: I73ba6871a9f0d410a7b3818833a1f50a5f75fba6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117203
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2019-09-18 18:35:59 +00:00
Jens Johansen cae08c6813 [CFE] Apply lines_longer_than_80_chars lint
Change-Id: I35b62b34d3ccc7098c21a680a80612c0bb927123
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113030
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-08-15 10:01:20 +00:00
Dan Rubel 3c05b8199b move identifier recovery into scanner
Change-Id: I1e4f4fa900b72e4fd405ae8dc86dfa9bc13f370f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110183
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-07-24 18:38:43 +00:00
Dan Rubel 24d1e511df improve missing hex digit recovery
Change-Id: I12d9e3fe314e850a6ee9599187d67dfa5455b18a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110143
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-07-24 18:38:43 +00:00
Dan Rubel 9c148623c5 prepend missing hex digits error token
This prepends (rather than append) another error token to the token stream
similar to https://dart-review.googlesource.com/c/sdk/+/110100

In addition, this addresses a comment in
https://dart-review.googlesource.com/c/sdk/+/110140

Change-Id: I27c739b0ee3213cdbce92c3ff18c31fde862251c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110141
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2019-07-23 18:08:37 +00:00
danrubel 7983fac33b add "extension" built-in keyword for extension methods
Change-Id: I6529fff31f681fd24c22f8c7579d2a35097f4d07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2019-05-17 22:24:15 +00:00
danrubel a83fbc5edb remove unused enable lazyAssignmentOperators flag
Change-Id: I4112fe4ad5a08916d124216753a995d607a9892d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101485
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2019-05-07 13:06:39 +00:00
danrubel 1d7dcfff97 Cleanup scanner tests
Change-Id: I9d579b136c6ff8f83cea1715f3e698eeca8692f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97446
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2019-03-21 15:01:18 +00:00
Sam Rawlins 3154bb0d37 Stop using external deprecated members in front_end
Change-Id: I3fa03de568f72bfc3adb46efcfa2b61b781c706b
Reviewed-on: https://dart-review.googlesource.com/c/89020
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2019-01-15 18:55:10 +00:00
Peter von der Ahé 3a2308f5c2 Move jenkins_smi_hash to package:analyzer
Change-Id: Ic458da90e5bdb6b3b7fee26088b17dd560ff3a68
Reviewed-on: https://dart-review.googlesource.com/c/77861
Commit-Queue: Peter von der Ahé <ahe@google.com>
Auto-Submit: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-04 07:43:09 +00:00
Nate Bosch 0f45b2e5c9 Fix spelling hexidecimal -> hexadecimal
Fixes #34460

Change-Id: I43ce8bbad9bfcc6b14c3a537ada84107e7bfaffe
Reviewed-on: https://dart-review.googlesource.com/74940
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2018-09-15 01:19:06 +00:00
Dan Rubel 8c7e83aed2 Remove generic method comment support
Change-Id: I1149ff9c61748fe8d3a51c95e40c02ec5115b0e7
Reviewed-on: https://dart-review.googlesource.com/72122
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-08-30 17:52:40 +00:00
danrubel ec505fe330 Remove more old scanner tests
Change-Id: I96775140766e43f33b3e63cdaaa3a301847d77b8
Reviewed-on: https://dart-review.googlesource.com/65923
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-07-21 14:13:46 +00:00
Kevin Millikin 6213303e65 Fix some runtime check failures in tests
Fix some Dart 2 runtime check failures due to inferred List<dynamic>.

Change-Id: I09215629d4d6c70cd56930b0d19de2a092a7facd
Reviewed-on: https://dart-review.googlesource.com/58208
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-06-06 08:09:58 +00:00
Lasse R.H. Nielsen a4494a7fb2 Make mixin and interface built-in identifiers.
Fixes #33113

Bug: http://dartbug.com/33113
Change-Id: I4b0b7c9d82ae9df6a7e9f71168ca981c62c7a2f1
Reviewed-on: https://dart-review.googlesource.com/55222
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-05-18 09:57:17 +00:00
Dan Rubel 6f710ee546 Update AstBuilder to report scanner errors
Change-Id: I7b33a86378a7c816ccdfb1a7e0869ccd5c3b8f7c
Reviewed-on: https://dart-review.googlesource.com/43900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-27 17:20:58 +00:00
Dan Rubel 2b681b2149 Disable scanning of &&= and ||= assignment operators
Fix https://github.com/dart-lang/sdk/issues/30340

Change-Id: Id27f37af9805ca09deaa3c6252817e3d9a926216
Reviewed-on: https://dart-review.googlesource.com/17361
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-10-31 18:51:24 +00:00
Dan Rubel 0b93c279e7 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

Review-Url: https://codereview.chromium.org/2981343002 .
2017-07-26 10:37:19 -04:00
Dan Rubel f8655ca568 update invalid hex digit recovery
* update invalid hex digit recovery for compatibility with analyzer
* address comments from https://codereview.chromium.org/2915093002

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2941583003 .
2017-06-14 11:18:34 -04:00
Dan Rubel c36936f37f translate remaining fasta scanner error codes
This updates the fasta scanner to translate the remaining
previously untranslated error codes so that they will be seen
by the analyzer when the fasta scanner is used by analyzer.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2923113002 .
2017-06-06 09:08:13 -04:00
Dan Rubel c4449efa33 improve handling of missing interpolation identifier
When the fasta scanner finds a STRING_INTERPOLATION_IDENTIFIER token '$'
without an identifier, it now inserts a synthetic identifier

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2922563002 .
2017-06-02 15:16:44 -04:00
Dan Rubel b61f9f2343 improve fasta unterminated string recovery
This updates the fasta scanner
to append synthetic closing quotes to unterminated strings.

Rework of https://codereview.chromium.org/2912693002/

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2915093002 .
2017-06-02 11:51:11 -04:00
Dan Rubel 767d5ecbfd Revert "improve fasta unterminated string recovery"
This reverts commit 6907345fb9.

Review-Url: https://codereview.chromium.org/2907093002 .
2017-05-28 23:40:08 -04:00
Dan Rubel 6907345fb9 improve fasta unterminated string recovery
* enhance handling of unterminated strings
* update ast builder and string validator to handle unterminated strings

Review-Url: https://codereview.chromium.org/2906193004 .
2017-05-28 23:35:32 -04:00
Dan Rubel 8928329339 improve fasta interpolation recovery
* improve fasta interpolation recovery by adding closing brace
    for unterminated string
* update analyzer scanner test because fasta does not support
    does not support \r line endings

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2910583002 .
2017-05-26 08:43:48 -04:00
Dan Rubel 3b790e5311 new TokenType and Keyword API
This adds two new methods and adapts most of the old references
to use these new API. Once all call sites have been updated,
the old API can be removed.

This is part one of https://codereview.chromium.org/2842643004/

* replace type == TokenType.KEYWORD with type.isKeyword
* change Keyword.syntax --> Keyword.lexeme

R=paulberry@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2842213003 .
2017-04-26 15:53:58 -04:00
Dan Rubel 4b8a2eb03b enhance analyzer to parse uppercase and built-in/pseudo keywords
Retrying https://codereview.chromium.org/2803563003

* update analyzer.Keyword list to include all of the fasta keywords

* enhance the analyzer scanner keyword table to handle uppercase
  keywords such as "Function"

* update analyzer's parser to process the new KeywordTokens

* fix analyzer error verification

* update translation of fasta <--> analyzer tokens

* update tests and cleanup analyzer warnings

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2799133003 .
2017-04-06 15:24:53 -04:00
Dan Rubel c22c6bad6c flag to enable fasta scanner in analyzer
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2784363002 .
2017-03-30 14:16:12 -04:00
Dan Rubel 4a783d1465 move synthetic fasta closers into the token stream
* add new SyntheticSymbolToken class

* whenever fasta inserts a closer ( '}', ']', ')' ) that is not part
  of the original source, ensure that the inserted closer is
  synthetic (isSynthetic returns true) and in the token stream

* make EOF a synthetic token

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2777153002 .
2017-03-29 15:02:12 -04:00
Dan Rubel 186c6f23bd fasta scanner recovery and error code translation improvements
* cleanup defaultRecoveryStrategy next/previous and eof

* add SymbolToken.eof() constructor to ensure that EOF tokens
  are correctly self referencing

* add fasta.scanString method to match scan method

* add fasta.ScannerResult.hasErrors field
  so that scan and scanString callers can quickly check for errors

* new scanner replacement test
  which scans using fasta then asserts as if it were from analyzer

* improve SymbolToken.toString() for EOF
* update analyzer test :: fasta scanner considers "<" to be an opener
* extract and move translateErrorToken into front_end
* address comments in https://codereview.chromium.org/2763833002

R=ahe@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/2767083002 .
2017-03-24 11:40:22 -04:00
Dan Rubel dbe5e64c8f fix token type of first token in converted token stream
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2701723002 .
2017-02-21 12:18:42 -05:00
Paul Berry c239c221eb Comment improvements
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2701493002 .
2017-02-15 10:37:01 -08:00
Paul Berry cf6a01be19 When translating analyzer/fasta token streams, match up begin/end tokens.
This required adding some scanner tests in order to validate the translation.

Note that the Fasta scanner considers "<", ">", and ">>" to be
grouping tokens (with special rules to avoid problems when "<" is used
to mean "less than"); analyzer does not.  The translation does not
handle this correctly yet.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2690073003 .
2017-02-14 04:46:36 -08:00
Paul Berry 02ff6326d7 Remove unused TokenType.IS.
TokenType is used for symbols, not keywords.

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2691043003 .
2017-02-13 11:17:02 -08:00
Paul Berry f0e657015d Add the ability to convert an analyzer token stream to a Fasta one.
This will be needed in order to integrate Fasta into the existing
analyzer codebase, because the analyzer task model considers the
parser and scanner to be separate black boxes with an analyzer token
stream in between.  In order for Fasta to be able to drop into those
black boxes, we will need to be able to convert Fasta tokens to
analyzer tokens after scanning, and then back to Fasta tokens prior to
parsing.

Tested via a "round trip" test that converts the analyzer token stream
into a Fasta token stream and then back.

Note that the transformation is not perfect; it currently fails to
recreate error tokens and it fails to hook up the connection between a
BeginGroup token and the corresponding end token.  But it is enough to
be able to pass tests for now.  It will be improved (and tests will be
expanded) in future CLs.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2689733003 .
2017-02-13 10:24:49 -08:00
Paul Berry fbcce6192c Stop testing scanner error lengths.
The scanner has always reported all errors as having a length of 1;
trying to test that each error has the expected length just creates
confusion.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2694433002 .
2017-02-10 11:09:32 -08:00
Paul Berry 7e283248e1 Use Keyword.isPseudo to translate Fasta's "pseudo-keywords" properly.
With the exception of `deferred`, all of Fasta's "pseudo-keywords" are
considered by the analyzer (and the spec) to be identifiers.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2686293002 .
2017-02-10 10:59:06 -08:00
Paul Berry 85028a844f Unify fasta->analyzer token translation logic.
Previously, the scanner tests and the Fasta implementation had
duplicate logic for translating Fasta tokens to analyzer tokens.  This
CL unifies the translation logic, and fills in some functionality that
was missing from the Fasta translation logic.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2682423003 .
2017-02-10 09:01:55 -08:00
Paul Berry 6c86822bf5 Separate fasta and analyzer scanner tests.
This makes it easier to run one set of tests or the other.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2680903002 .
2017-02-07 17:36:52 -08:00
Paul Berry e29f83feeb Modify fasta scanner testing logic to use ErrorToken.errorCode.
Fixes 6 failing tests.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2674353002 .
2017-02-07 06:36:00 -08:00
Paul Berry a4f8db2c0b Use token.value to distinguish comment types.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2674383002 .
2017-02-07 05:57:21 -08:00
Paul Berry 04f19f6bfb Connect fasta's scanner to the analyzer-derived scanner tests in front_end.
Failing tests are currently marked with "@failingTest" to prevent
breaking buildbots.

I've marked the issues I'm aware of with "TODO(paulberry,ahe)".  Peter
and I need to triage these issues--some of them may not be necessary
to fix due to the fact that fasta replaces the parser as well.  We
will follow up with CLs that either fix the issues or remove the TODO
comments as appropriate.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2676083002 .
2017-02-06 05:54:15 -08:00