Commit Graph

26 Commits

Author SHA1 Message Date
Erik Ernst 05ae94dc91 Support static abstract variables and require initializers
This CL adds a grammar rule to Dart.g and Dart.g4 such that a
variable declaration can be `static abstract`. It also changes the rule
for `static final` and `static const` variable declarations such that
it is a syntax error if they do not have an initializing expression.

This restores the approach which was used before augmentations were
added. It is possible to do this because the added flexibility
would only allow cases which are intended to be an error, because it
is no longer possible to "override" or "extend" an implementation
in an augmenting declaration.

Change-Id: Id7696880a948697678eaf368c69c390b9c8f4e7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485440
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-03-04 04:24:07 -08:00
Erik Ernst 92c362a8b0 Align the specification parser with recent specification changes
This CL aligns Dart.g/Dart.g4 with the feature specs for
augmentations and primary constructors such that they allow for all
kinds of membered declaration bodies to be expressed as `;`.

Change-Id: I61fe4b4fe6541fd0962f8ca39590611827c1d127
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483340
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-03-04 03:30:23 -08:00
Erik Ernst 2a475cfe9e Align the specification grammar with the specifications
Adjust Dart.g and Dart.g4 to align them with the augmentations feature
specification and the language specification. In particular, the
handling of the keyword AUGMENT is simplified, and `topLevelDefinition`
is renamed.

Change-Id: I99dc5c6e5e3135eae14f49587d60c530e303f0e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476401
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Auto-Submit: Erik Ernst <eernst@google.com>
2026-01-29 02:54:31 -08:00
Erik Ernst 391212f3da Update the specification grammar
The augmentations feature has been modified over a period of time.
This CL introduces the associated grammar changes into the
specification grammars.

Change-Id: Iaa4cdd4c3ffea26ac327265468d68fae59efb2fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2025-12-12 04:53:59 -08:00
Erik Ernst d06e6956e8 Update spec parser rules about primary constructors
This CL changes Dart.g and Dart.g4 such that the spec parser will
parse primary constructors using a simpler and clearer set of rules.
In particular, the body part of a primary constructor has been given
its own signature (`primaryConstructorBodySignature`), which makes it
easier to denote the constructs which are used along with primary
constructors, and it also supports a more comprehensible AST structure.

Change-Id: I7c211ecd76596927a044bdedc5dec3a7eaf9a8b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2025-11-10 00:30:12 -08:00
Erik Ernst 5656806517 Update the spec parser to support new();`
This CL changes the spec parser specification (Dart.g and Dart.g4) such
that the grammar allows for the new style of constructor declarations
(such as `new();` and `new name();`). It also adjusts the declaring body
constructor syntax to use the same style (`this();` and `this name();`).
Finally, it updates a few non-terminals to use a naming that avoids the
ambiguity of `classNamePart`. These changes introduce about 5 new
failures when parsing $SDK/tests/language.

Change-Id: I3e6ac9f0782e3bde863a13c93a54a089c93c7e13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456640
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2025-11-03 01:35:25 -08:00
Erik Ernst 149af9d3ae Simplify primary constructor grammar rule
This CL simplifies the grammar rule for a primary constructor and the
place where it's used (`classNamePart`) - the proposal no longer uses
a version that cannot have the modifier `const`. Also, it de-inlines
`typeWithParameters` for consistency and brevity.

Change-Id: Idbd2182a6a29256d61c617c9eb2f631213cb3234
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455400
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2025-10-20 01:31:44 -07:00
Erik Ernst ad5a1bb54f Simplify the grammar to use just memberDeclaration
The spec_parser grammars have previously made a distinction among the
different kinds of members that a class, mixin, extension type, etc
could have. This is not very useful, though, so this CL changes the
grammar such that they all just contain a sequence of general member
declarations `<memberDeclaration>`. It is then up to non-parser based
error checks to prevent whatever should not exist (e.g., until we add
constructors to extensions it is an error to declare a constructor in
an `extension`, but this will be an ad-hoc check rather than a syntax
error).

Change-Id: Ifca2713af86eb3f569732ebef844135b772a5465
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454280
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2025-10-09 04:11:18 -07:00
Erik Ernst 37c3b5b443 Add support for declaring constructors to the spec parser
Also fixes a bug whereby the file name message came after the first
syntax error diagnostic for each file.

Change-Id: Ice2da1e337fa54787696989b387d057ab5674819
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453280
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-10-03 05:29:00 -07:00
Erik Ernst 0566b169a6 Update Dart.g & Dart.g4 to match newest version of spec
Change-Id: I10a0527577439cb9ea1d94d60b31703995d7f6b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397905
Commit-Queue: Erik Ernst <eernst@google.com>
Auto-Submit: Erik Ernst <eernst@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-11-28 12:07:35 +00:00
Erik Ernst bc30907b73 Add support for static access shorthands
Change-Id: I826e230ad38388a8e1f6ccc366704a2e8c340dee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397301
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-11-25 15:28:39 +00:00
Erik Ernst fc7b4dda66 Adjust tests and spec_parser to updated grammar
This CL changes the specification parser grammar to support a switch
expression that has zero cases (this is a missing update, the feature
specification already has it). It also changes several language tests
such that they expect a 'syntax error' rather than a 'compile-time
error'. This makes no difference for any tool except the specification
parser, for which it is needed (in general, a test that is expected
to have a compile-time error will parse just fine, so we need a
separate test outcome expectation for syntax errors).

Change-Id: Ifa00c11ce6c57053bd490e11a41d6e8d7b82a2d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384600
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-09-27 15:29:03 +00:00
Erik Ernst 986626a532 Enable augmentation of additional kinds of declaration
This CL adds support in the grammar for augmenting external top-level
declarations (getter, setter, function, variable). It also adds this
support to several kinds of declarations, and then factors out the
`AUGMENT?` part of each alternative of `declaration` (because we are
now allowing `augment` on every alternative).

This CL is a continuation of
https://dart-review.googlesource.com/c/sdk/+/387160
where the first batch of changes in this area were made.

Change-Id: I7f02709f29d0f13010ac44c4428f90250a38948c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387221
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-09-27 12:29:38 +00:00
Erik Ernst ec891471f5 Add support in Dart.g for separators in numeric literals
Change-Id: I2b0ba97b9b89803b28358b94959e31276eda3af2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387222
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-09-27 12:24:40 +00:00
Erik Ernst 582abe2bbb Add support for omission of implementation as per #4015
This CL adds support in the specification parser (Dart.g) for omitting
the implementation from several kinds of declarations. This is needed
because it must be possible to omit the implementation and provide it
in an augmentation.

The implementation is the initializing expression of a variable, the
function body of a top-lovel or static getter, setter, or method, or
the function body of a factory constructor.

Change-Id: If305dae376ba1c5aabcdd698824aca5d5b0fb97a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387160
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-09-27 07:47:29 +00:00
Erik Ernst 465bbbd720 Update the spec parser to support enhanced parts
Change-Id: I6904294f473d1c9a861ad385e14e17bdd79189d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386560
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-09-25 06:52:42 +00:00
Erik Ernst 812b03da64 Make augment a built-in identifier
This was done in the feature specification in v1.10, but it wasn't
done in the specification parser at the time. This CL corrects that
omission.

Change-Id: I03d54e8f6a369abd5d2be8fb281e8f3abd2cb85d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386240
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-09-24 13:24:02 +00:00
Erik Ernst 00070c74bd Add support for parts with imports in Dart.g
This CL adds support for having import and export directives in a part
file, following the 'parts with imports' feature proposal. It is
needed at this time because tests are being written where some parts
do have imports and exports, and those tests shouldn't give rise to a
parsing failure.

Change-Id: I70076c7b0bd8795a60983306a8b40e7bc55a863b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384282
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-09-10 08:23:19 +00:00
Erik Ernst f019c8188d Update the specification parser to follow language repo #4016
The PR https://github.com/dart-lang/language/pull/4016 updates the
augmentation feature specification such that augmenting extension type
declarations do not specify the primary constructor. This CL changes
Dart.g (and hence the specification parser) accordingly.

It also corrects a typo in Dart.g.

Change-Id: I10b49873a96524a9d363f842b39688f3c624b9f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379100
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-08-07 15:43:29 +00:00
Erik Ernst b56843da32 Spec parse null aware elements
Change-Id: Ib61fea3bec110c0a2c560c965912c51a1c4e22cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368569
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-05-31 09:12:01 +00:00
Erik Ernst 035be2b0d4 Update Dart.g to clarify the association of metadata and its target AST
Change-Id: I02a3e155aab73d638ddbc20485db9db3dcbe6c9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365781
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-05-21 09:07:23 +00:00
Erik Ernst a873a14700 Update augmented extensionDeclaration, following PR 3701
Change-Id: I9616ec821ce5eddccd732313f0edc8c300a702b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362200
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-04-11 14:21:28 +00:00
Erik Ernst 555e38db9b Add enumEntry grammar update for augmentations
An `enumEntry` needs to allow for the keyword `augment` in order to
enable augmentation libraries. This CL performs a grammar rule update
in Dart.g and Dart.g4, such that this keyword can be included.

The corresponding change to the feature specification was performed in
https://github.com/dart-lang/language/pull/3688.

Change-Id: I6d6a3f09754a76da668dfc84cd20a7df812ecdbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360642
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-04-03 08:36:38 +00:00
Erik Ernst 50ff1c7823 Introduce support for augmentation libraries in Dart.g
Change-Id: Icc4b89f1b25dd633279d87e9d51f85372d962c7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358450
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2024-03-20 17:10:53 +00:00
Erik Ernst 20f197dacd Include the most recent updates on type modifiers in Dart.g
The class modifiers feature specification was updated such that mixins
cannot be `sealed`, and several other combinations were eliminated.
This CL makes those changes to Dart.g. The changes have been in effect
for a while (8 months since last update to the spec), but the update
to Dart.g was somehow not performed at the time. This CL fixes that
omission.

Change-Id: Ifd2124583a124cdaaa7822f94f70e707ec33b425
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358460
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-03-19 11:44:03 +00:00
Modestas Valauskas e8b20f66b2 Add DSP.
Closes https://github.com/dart-lang/sdk/pull/54781

GitOrigin-RevId: 10439cd7c0da0bc3803cd6f2cfc3133ddb75f087
Change-Id: I6e569b65509dd333daf5c3bb515709f0be03fa89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349408
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-02-06 19:07:13 +00:00