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>
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
// CHANGES:
|
||||
//
|
||||
// v0.54 Simplify members.
|
||||
//
|
||||
// v0.53 Support declaring constructors.
|
||||
//
|
||||
// v0.52 Support static access shorthands.
|
||||
@@ -435,7 +437,7 @@ classNamePart
|
||||
;
|
||||
|
||||
classBody
|
||||
: LBRACE (metadata classMemberDeclaration)* RBRACE
|
||||
: LBRACE (metadata memberDeclaration)* RBRACE
|
||||
| ';'
|
||||
;
|
||||
|
||||
@@ -461,7 +463,7 @@ interfaces
|
||||
: IMPLEMENTS typeNotVoidNotFunctionList
|
||||
;
|
||||
|
||||
classMemberDeclaration
|
||||
memberDeclaration
|
||||
: AUGMENT? methodSignature functionBody
|
||||
| AUGMENT? declaration ';'
|
||||
;
|
||||
@@ -473,11 +475,7 @@ mixinApplicationClass
|
||||
mixinDeclaration
|
||||
: AUGMENT? BASE? MIXIN typeWithParameters
|
||||
(ON typeNotVoidNotFunctionList)? interfaces?
|
||||
LBRACE (metadata mixinMemberDeclaration)* RBRACE
|
||||
;
|
||||
|
||||
mixinMemberDeclaration
|
||||
: classMemberDeclaration
|
||||
LBRACE (metadata memberDeclaration)* RBRACE
|
||||
;
|
||||
|
||||
extensionTypeDeclaration
|
||||
@@ -487,25 +485,17 @@ extensionTypeDeclaration
|
||||
;
|
||||
|
||||
extensionTypeBody
|
||||
: LBRACE (metadata extensionTypeMemberDeclaration)* RBRACE
|
||||
: LBRACE (metadata memberDeclaration)* RBRACE
|
||||
| ';'
|
||||
;
|
||||
|
||||
extensionTypeMemberDeclaration
|
||||
: classMemberDeclaration
|
||||
;
|
||||
|
||||
extensionDeclaration
|
||||
: EXTENSION typeIdentifierNotType? typeParameters? ON type extensionBody
|
||||
| AUGMENT EXTENSION typeIdentifierNotType typeParameters? extensionBody
|
||||
;
|
||||
|
||||
extensionBody
|
||||
: LBRACE (metadata extensionMemberDeclaration)* RBRACE
|
||||
;
|
||||
|
||||
extensionMemberDeclaration
|
||||
: classMemberDeclaration
|
||||
: LBRACE (metadata memberDeclaration)* RBRACE
|
||||
;
|
||||
|
||||
methodSignature
|
||||
@@ -697,7 +687,7 @@ mixinApplication
|
||||
enumType
|
||||
: AUGMENT? ENUM classNamePart mixins? interfaces? LBRACE
|
||||
enumEntry (',' enumEntry)* ','?
|
||||
(';' (metadata classMemberDeclaration)*)?
|
||||
(';' (metadata memberDeclaration)*)?
|
||||
RBRACE
|
||||
;
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
// CHANGES:
|
||||
//
|
||||
// v0.55 Simplify members.
|
||||
//
|
||||
// v0.54 Support declaring constructors.
|
||||
//
|
||||
// v0.53 Support static access shorthands.
|
||||
@@ -445,7 +447,7 @@ classNamePart
|
||||
;
|
||||
|
||||
classBody
|
||||
: LBRACE (metadata classMemberDeclaration)* RBRACE
|
||||
: LBRACE (metadata memberDeclaration)* RBRACE
|
||||
| ';'
|
||||
;
|
||||
|
||||
@@ -471,7 +473,7 @@ interfaces
|
||||
: IMPLEMENTS typeNotVoidNotFunctionList
|
||||
;
|
||||
|
||||
classMemberDeclaration
|
||||
memberDeclaration
|
||||
: AUGMENT? methodSignature functionBody
|
||||
| AUGMENT? declaration ';'
|
||||
;
|
||||
@@ -483,11 +485,7 @@ mixinApplicationClass
|
||||
mixinDeclaration
|
||||
: AUGMENT? BASE? MIXIN typeWithParameters
|
||||
(ON typeNotVoidNotFunctionList)? interfaces?
|
||||
LBRACE (metadata mixinMemberDeclaration)* RBRACE
|
||||
;
|
||||
|
||||
mixinMemberDeclaration
|
||||
: classMemberDeclaration
|
||||
LBRACE (metadata memberDeclaration)* RBRACE
|
||||
;
|
||||
|
||||
extensionTypeDeclaration
|
||||
@@ -497,26 +495,17 @@ extensionTypeDeclaration
|
||||
;
|
||||
|
||||
extensionTypeBody
|
||||
: LBRACE (metadata extensionTypeMemberDeclaration)* RBRACE
|
||||
: LBRACE (metadata memberDeclaration)* RBRACE
|
||||
| ';'
|
||||
;
|
||||
|
||||
extensionTypeMemberDeclaration
|
||||
: classMemberDeclaration
|
||||
;
|
||||
|
||||
extensionDeclaration
|
||||
: EXTENSION typeIdentifierNotType? typeParameters? ON type extensionBody
|
||||
| AUGMENT EXTENSION typeIdentifierNotType typeParameters? extensionBody
|
||||
;
|
||||
|
||||
extensionBody
|
||||
: LBRACE (metadata extensionMemberDeclaration)* RBRACE
|
||||
;
|
||||
|
||||
// TODO: We might want to make this more strict.
|
||||
extensionMemberDeclaration
|
||||
: classMemberDeclaration
|
||||
: LBRACE (metadata memberDeclaration)* RBRACE
|
||||
;
|
||||
|
||||
methodSignature
|
||||
@@ -708,7 +697,7 @@ mixinApplication
|
||||
enumType
|
||||
: AUGMENT? ENUM classNamePart mixins? interfaces? LBRACE
|
||||
enumEntry (',' enumEntry)* ','?
|
||||
(';' (metadata classMemberDeclaration)*)?
|
||||
(';' (metadata memberDeclaration)*)?
|
||||
RBRACE
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user