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>
This commit is contained in:
Erik Ernst
2026-01-29 02:54:31 -08:00
committed by Commit Queue
parent a6d78c53df
commit 2a475cfe9e
2 changed files with 18 additions and 12 deletions
+9 -6
View File
@@ -4,6 +4,9 @@
// CHANGES:
//
// v0.58 Gather some occurrences of `AUGMENT` in a single location. Rename
// `topLevelDefinition` to `topLevelDeclaration` (as in the specification).
//
// v0.57 Introduce augmentation related updates.
//
// v0.56 Update constructor declaration syntax to allow `constructorHead`.
@@ -292,11 +295,11 @@ libraryDeclaration
libraryName?
importOrExport*
partDirective*
(metadata topLevelDefinition)*
(metadata topLevelDeclaration)*
EOF
;
topLevelDefinition
topLevelDeclaration
: classDeclaration
| mixinDeclaration
| extensionTypeDeclaration
@@ -452,7 +455,7 @@ memberedDeclarationBody
;
memberDeclarations
: (metadata memberDeclaration)*
: (metadata AUGMENT? memberDeclaration)*
;
classModifiers
@@ -478,8 +481,8 @@ interfaces
;
memberDeclaration
: AUGMENT? methodSignature functionBody
| AUGMENT? declaration ';'
: methodSignature functionBody
| declaration ';'
;
mixinApplicationClass
@@ -1558,7 +1561,7 @@ partDeclaration
: FEFF? partHeader
importOrExport*
partDirective*
(metadata topLevelDefinition)*
(metadata topLevelDeclaration)*
EOF
;
+9 -6
View File
@@ -4,6 +4,9 @@
// CHANGES:
//
// v0.59 Gather some occurrences of `AUGMENT` in a single location. Rename
// `topLevelDefinition` to `topLevelDeclaration` (as in the specification).
//
// v0.58 Introduce augmentation related updates.
//
// v0.57 Update constructor declaration syntax to allow `constructorHead`.
@@ -302,11 +305,11 @@ libraryDeclaration
libraryName?
importOrExport*
partDirective*
(metadata topLevelDefinition)*
(metadata topLevelDeclaration)*
EOF
;
topLevelDefinition
topLevelDeclaration
: classDeclaration
| mixinDeclaration
| extensionTypeDeclaration
@@ -462,7 +465,7 @@ memberedDeclarationBody
;
memberDeclarations
: (metadata memberDeclaration)*
: (metadata AUGMENT? memberDeclaration)*
;
classModifiers
@@ -488,8 +491,8 @@ interfaces
;
memberDeclaration
: AUGMENT? methodSignature functionBody
| AUGMENT? declaration ';'
: methodSignature functionBody
| declaration ';'
;
mixinApplicationClass
@@ -1572,7 +1575,7 @@ partDeclaration
: FEFF? partHeader
importOrExport*
partDirective*
(metadata topLevelDefinition)*
(metadata topLevelDeclaration)*
EOF
;