Add support for mixin syntax
Created by: tobie
Hey,
We recently changed the WebIDL syntax to add support for mixins. We also added CI tooling to make sure the grammar stayed LL(1), and fixed a couple of issues in the process.
Here's an indicative diff of the recent grammar changes, but please do refer to the IDL index section in the spec for details:
--- (old)
+++ (new)
@@ -3,17 +3,13 @@
ε
Definition ::
- CallbackOrInterface
+ CallbackOrInterfaceOrMixin
Namespace
Partial
Dictionary
Enum
Typedef
- ImplementsStatement
-
-CallbackOrInterface ::
- callback CallbackRestOrInterface
- Interface
+ IncludesStatement
ArgumentNameKeyword ::
attribute
@@ -23,7 +19,7 @@
dictionary
enum
getter
- implements
+ includes
inherit
interface
iterable
@@ -38,23 +34,35 @@
typedef
unrestricted
+CallbackOrInterfaceOrMixin ::
+ callback CallbackRestOrInterface
+ interface InterfaceOrMixin
+
CallbackRestOrInterface ::
CallbackRest
- Interface
+ interface InterfaceRest
+
+InterfaceOrMixin ::
+ InterfaceRest
+ MixinRest
-Interface ::
- interface identifier Inheritance { InterfaceMembers } ;
+InterfaceRest ::
+ identifier Inheritance { InterfaceMembers } ;
Partial ::
partial PartialDefinition
PartialDefinition ::
- PartialInterface
+ interface PartialInterfaceOrPartialMixin
PartialDictionary
Namespace
-PartialInterface ::
- interface identifier { InterfaceMembers } ;
+PartialInterfaceOrPartialMixin ::
+ PartialInterfaceRest
+ MixinRest
+
+PartialInterfaceRest ::
+ identifier { InterfaceMembers } ;
InterfaceMembers ::
ExtendedAttributeList InterfaceMember InterfaceMembers
@@ -75,6 +83,22 @@
: identifier
ε
+MixinRest ::
+ mixin identifier { MixinMembers } ;
+
+MixinMembers ::
+ ExtendedAttributeList MixinMember MixinMembers
+ ε
+
+MixinMember ::
+ Const
+ RegularOperation
+ Stringifier
+ ReadOnly AttributeRest
+
+IncludesStatement ::
+ identifier includes identifier ;
+
Const ::
const ConstType identifier = ConstValue ;
@@ -130,11 +154,14 @@
[ ]
Operation ::
- ReturnType OperationRest
+ RegularOperation
SpecialOperation
+RegularOperation ::
+ ReturnType OperationRest
+
SpecialOperation ::
- Special Specials ReturnType OperationRest
+ Special Specials RegularOperation
Specials ::
Special Specials
@@ -161,8 +188,11 @@
ε
Argument ::
- ExtendedAttributeList optional TypeWithExtendedAttributes ArgumentName Default
- ExtendedAttributeList Type Ellipsis ArgumentName
+ ExtendedAttributeList ArgumentRest
+
+ArgumentRest ::
+ optional TypeWithExtendedAttributes ArgumentName Default
+ Type Ellipsis ArgumentName
ArgumentName ::
ArgumentNameKeyword
@@ -181,7 +211,7 @@
StringifierRest ::
ReadOnly AttributeRest
- ReturnType OperationRest
+ RegularOperation
;
StaticMember ::
@@ -189,7 +219,7 @@
StaticMemberRest ::
ReadOnly AttributeRest
- ReturnType OperationRest
+ RegularOperation
Iterable ::
iterable < TypeWithExtendedAttributes OptionalType > ;
@@ -218,7 +248,7 @@
ε
NamespaceMember ::
- ReturnType OperationRest
+ RegularOperation
readonly AttributeRest
Dictionary ::
@@ -229,8 +259,11 @@
ε
DictionaryMember ::
- ExtendedAttributeList required TypeWithExtendedAttributes identifier Default ;
- ExtendedAttributeList Type identifier Default ;
+ ExtendedAttributeList DictionaryMemberRest
+
+DictionaryMemberRest ::
+ required TypeWithExtendedAttributes identifier Default ;
+ Type identifier Default ;
PartialDictionary ::
dictionary identifier { DictionaryMembers } ;
@@ -259,16 +292,12 @@
Typedef ::
typedef TypeWithExtendedAttributes identifier ;
-ImplementsStatement ::
- identifier implements identifier ;
-
Type ::
SingleType
UnionType Null
TypeWithExtendedAttributes ::
- ExtendedAttributeList SingleType
- ExtendedAttributeList UnionType Null
+ ExtendedAttributeList Type
SingleType ::
NonAnyType
Let me know if there's anything I can do to help!
Tracked in: heycam/webidl#472 | Original pull-request: heycam/webidl#433