diff --git a/tools/spec_parser/Dart.g b/tools/spec_parser/Dart.g index 6951a0df445..1092408dc63 100644 --- a/tools/spec_parser/Dart.g +++ b/tools/spec_parser/Dart.g @@ -4,6 +4,9 @@ // CHANGES: // +// v0.59 Adjust augmentation and primary constructor related rules to match +// recent updates. +// // v0.58 Gather some occurrences of `AUGMENT` in a single location. Rename // `topLevelDefinition` to `topLevelDeclaration` (as in the specification). // @@ -314,7 +317,7 @@ topLevelDeclaration | AUGMENT? getterSignature (functionBody | ';') | AUGMENT? setterSignature (functionBody | ';') | AUGMENT? functionSignature (functionBody | ';') - | AUGMENT? (FINAL | CONST) type? initializedIdentifierList ';' + | AUGMENT? (FINAL | CONST) type? staticFinalDeclarationList ';' | AUGMENT? LATE FINAL type? initializedIdentifierList ';' | AUGMENT? LATE? varOrType initializedIdentifierList ';' ; @@ -544,6 +547,14 @@ declaration | primaryConstructorBodySignature ; +staticFinalDeclarationList + : staticFinalDeclaration (',' staticFinalDeclaration)* + ; + +staticFinalDeclaration + : identifier '=' expression + ; + operatorSignature : type? OPERATOR operator formalParameterList ; @@ -705,12 +716,14 @@ mixinApplication enumType : AUGMENT? ENUM classNameMaybePrimary mixins? interfaces? - LBRACE enumBody? RBRACE + enumBody ; enumBody - : enumEntry (',' enumEntry)* ','? (';' memberDeclarations)? - | ';' memberDeclarations + : LBRACE + (enumEntry (',' enumEntry)* ','?)? (';' memberDeclarations)? + RBRACE + | ';' ; enumEntry diff --git a/tools/spec_parser/dart_spec_parser/Dart.g4 b/tools/spec_parser/dart_spec_parser/Dart.g4 index bdea3a1a7f4..a60b55b3a3b 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.60 Adjust augmentation and primary constructor related rules to match +// recent updates. +// // v0.59 Gather some occurrences of `AUGMENT` in a single location. Rename // `topLevelDefinition` to `topLevelDeclaration` (as in the specification). // @@ -324,11 +327,19 @@ topLevelDeclaration | AUGMENT? getterSignature (functionBody | ';') | AUGMENT? setterSignature (functionBody | ';') | AUGMENT? functionSignature (functionBody | ';') - | AUGMENT? (FINAL | CONST) type? initializedIdentifierList ';' + | AUGMENT? (FINAL | CONST) type? staticFinalDeclarationList ';' | AUGMENT? LATE FINAL type? initializedIdentifierList ';' | AUGMENT? LATE? varOrType initializedIdentifierList ';' ; +staticFinalDeclarationList + : staticFinalDeclaration (',' staticFinalDeclaration)* + ; + +staticFinalDeclaration + : identifier '=' expression + ; + declaredIdentifier : COVARIANT? finalConstVarOrType identifier ; @@ -719,12 +730,14 @@ mixinApplication enumType : AUGMENT? ENUM classNameMaybePrimary mixins? interfaces? - LBRACE enumBody? RBRACE + enumBody ; enumBody - : enumEntry (',' enumEntry)* ','? (';' memberDeclarations)? - | ';' memberDeclarations + : LBRACE + (enumEntry (',' enumEntry)* ','?)? (';' memberDeclarations)? + RBRACE + | ';' ; enumEntry