From 783abcd4e87a6712abcc0681e413ce8a8dca13b9 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Mon, 22 May 2023 14:09:48 +0000 Subject: [PATCH] Add suport for inline classes in Dart.g Change-Id: I63b829e107458268d91b39e7f0abb673dc20d0f7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304004 Commit-Queue: William Hesse Auto-Submit: Erik Ernst Reviewed-by: William Hesse --- tools/spec_parser/Dart.g | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/spec_parser/Dart.g b/tools/spec_parser/Dart.g index 6605bd9b57f..248d74debdd 100644 --- a/tools/spec_parser/Dart.g +++ b/tools/spec_parser/Dart.g @@ -4,6 +4,8 @@ // CHANGES: // +// v0.34 Add support for inline classes. +// // v0.33 This commit does not change the derived language at all. It just // changes several rules to use the regexp-like grammar operators to simplify // onParts, recordLiteralNoConst, functionTypeTails, and functionType. @@ -244,6 +246,7 @@ libraryDefinition topLevelDefinition : classDeclaration | mixinDeclaration + | inlineClassDeclaration | extensionDeclaration | enumType | typeAlias @@ -431,6 +434,16 @@ mixinMemberDeclaration : classMemberDeclaration ; +inlineClassDeclaration + : FINAL? INLINE CLASS typeWithParameters interfaces? + LBRACE (metadata inlineMemberDeclaration)* RBRACE + ; + +// TODO: We might want to make this more strict. +inlineMemberDeclaration + : classMemberDeclaration + ; + extensionDeclaration : EXTENSION identifier? typeParameters? ON type LBRACE (metadata extensionMemberDefinition)* RBRACE @@ -1613,6 +1626,7 @@ otherIdentifier : ASYNC | BASE | HIDE + | INLINE | OF | ON | SEALED @@ -1898,6 +1912,10 @@ HIDE : 'hide' ; +INLINE + : 'inline' + ; + OF : 'of' ;