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>
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>
'SpecParser.java' has always been using an `ANTLRFileStream`, but this
class has been deprecated at this time. Changing the code to use
`CharStreams.fromFileName(...)`.
Change-Id: I35fce3b381ac2e819794c08faef7f97c4c3bea50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444840
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
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>
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>
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>
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>
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>
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>
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>
The specification grammar has a rule for `initializerExpression` that
derives only `cascade` and `conditionalExpression`, whereas the
implementations allow throw expressions and assignments as well.
This CL broadens the grammar rule for `initializerExpression` such
that it derives the missing terms as well.
Change-Id: Iba3bb11623e07ac81cf9763228ae3e1b7b5204e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340620
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
This CL changes the specification grammar Dart.g such that it allows
using `p.Function` to denote the built-in type `Function`. This is
necessary in the case where 'dart:core' has been imported with an
import prefix `p` (and it hasn't been imported without a prefix at the
same time). The corresponding spec update is in
https://github.com/dart-lang/language/pull/3492.
Change-Id: Iaaba1c3bc8f5d3a8700c8e62ec3a1af92334840b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339561
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
A named optional parameter could previously be equipped with a default
value using ':' or '=' (as in `void f({int i : 1})` or `... i = 1 ...`).
The language has now (Dart 3.0) been updated to eliminate the form
using ':' (it has been deprecated for a long time).
This CL updates the spec_parser accordingly.
Change-Id: I28f9ec605699a9ffb2f7349a6a4b698fa709247b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313482
Commit-Queue: Erik Ernst <eernst@google.com>
Auto-Submit: Erik Ernst <eernst@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: William Hesse <whesse@google.com>
This CL adds/changes the specification grammar to support the upcoming 'class modifiers' feature. Also, it changes the rule about `superclass` to agree with the language specification (it is easy to see that it derives the same set of programs). Also introduces a non-terminal `otherIdentifier` listing those words which are not reserved, not built-in, but are still explicitly mentioned in grammar (e.g., `show`, `on`, and others). This is safer than maintaining a repeated list of words multiple places in the grammar.
Change-Id: I23dc303f9f9a06a665e19f375fe23378042434c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283183
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
By mistake, the update to the language specification grammar in commit
b26e7287c318c0112610fe8b7e175289792dfde2, May 2021, was not performed
in Dart.g (it's the generalization that allows method invocations of
the form `super(...)` or `super<...>(...)`). This CL adds the needed
alternative to the grammar rule `primary`.
This CL also changes the order of the alternatives in the `primary`
rule such that it matches the ordering of alternatives in the language
specification.
Change-Id: I34092975d1de1e522b0262017686673b7ea7e9e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279092
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
This CL changes the Dart grammar in Dart.g such that it contains all
the grammar changes applied to the patterns proposal since the previous
update of Dart.g.
Change-Id: I9b5f0d9a092d30ce0055db99da5fdbe3b9b1d5dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275002
Reviewed-by: William Hesse <whesse@google.com>
Auto-Submit: Erik Ernst <eernst@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
This CL changes the spec parser grammar, Dart.g, such that its pattern
related rules correspond to the recent updates in the patterns feature
specification.
Change-Id: I8d07cdb4c7ce22e0625da5bc8224ca2cf57af095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268920
Reviewed-by: William Hesse <whesse@google.com>
Auto-Submit: Erik Ernst <eernst@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>