From 2a475cfe9e04b9c0a5c0d80cee265bfcbdd04ee6 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Thu, 29 Jan 2026 02:54:31 -0800 Subject: [PATCH] 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 Commit-Queue: Chloe Stefantsova Auto-Submit: Erik Ernst --- tools/spec_parser/Dart.g | 15 +++++++++------ tools/spec_parser/dart_spec_parser/Dart.g4 | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/spec_parser/Dart.g b/tools/spec_parser/Dart.g index b5ec6e0af3e..6951a0df445 100644 --- a/tools/spec_parser/Dart.g +++ b/tools/spec_parser/Dart.g @@ -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 ; diff --git a/tools/spec_parser/dart_spec_parser/Dart.g4 b/tools/spec_parser/dart_spec_parser/Dart.g4 index b47e13c5644..bdea3a1a7f4 100644 --- a/tools/spec_parser/dart_spec_parser/Dart.g4 +++ b/tools/spec_parser/dart_spec_parser/Dart.g4 @@ -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 ;