This is a comparison of the "official" D2 grammar extracted from the website and a proposed grammar that is used by the Visual D parser. Some changes are cosmetic (like removal of empty clauses and preferring optional elements instead), but others make syntactic differences that might need to be discussed.
Some changes make sense for a grammar to be fed into a parser generator, but the website version might be better for understanding the language design (e.g. merging all possible DeclDefs).
| Proposed | Website | |
| Module: | = | Module: |
| ModuleDeclaration DeclDefsopt | <> | ModuleDeclaration DeclDefs |
| DeclDefsopt | DeclDefs |
DeclDefs is never empty.
| Proposed | Website | |
| = | ||
| ModuleDeclaration: | ModuleDeclaration: | |
| module ModuleFullyQualifiedName ; | module ModuleFullyQualifiedName ; | |
| ModuleFullyQualifiedName: | ModuleFullyQualifiedName: | |
| ModuleName | ModuleName | |
| Packages . ModuleName | Packages . ModuleName | |
| ModuleName: | ModuleName: | |
| Identifier | Identifier | |
| Packages: | Packages: | |
| PackageName | PackageName | |
| Packages . PackageName | Packages . PackageName | |
| PackageName: | PackageName: | |
| Identifier | Identifier | |
| DeclDefs: | DeclDefs: | |
| DeclDef | DeclDef | |
| DeclDef DeclDefs | DeclDef DeclDefs | |
| DeclDef: | DeclDef: | |
| AttributeSpecifier | AttributeSpecifier | |
| ImportDeclaration | ImportDeclaration | |
| EnumDeclaration | EnumDeclaration | |
| ClassDeclaration | ClassDeclaration | |
| InterfaceDeclaration | InterfaceDeclaration | |
| AggregateDeclaration | AggregateDeclaration | |
| Declaration | Declaration | |
| Constructor | Constructor | |
| Destructor | Destructor | |
| Invariant | Invariant | |
| UnitTest | UnitTest | |
| DebugSpecification | <> | StaticConstructor |
| VersionSpecification | StaticDestructor | |
| SharedStaticConstructor | ||
| SharedStaticDestructor | ||
| ConditionalDeclaration | = | ConditionalDeclaration |
| StaticAssert | StaticAssert | |
| TemplateDeclaration | TemplateDeclaration | |
| TemplateMixinDeclaration | +- | |
| TemplateMixin | = | TemplateMixin |
| MixinDeclaration | MixinDeclaration | |
| ClassAllocator | +- | |
| ClassDeallocator | ||
| AliasThis | ||
| ; | = | ; |
A list of declarations is needed in a lot of places, and it will blow up the grammar a lot to list only allowed declarations inside conditionals and attribute specifier blocks and others depending on usage inside struct, class, interface, etc. A parser can verify whether a DeclDef is allowed depending on the current enclosing scope.
Static and shared constructors have been removed, because they are already covered by the AttributeSpecifier clause. It is unclear whether this should declare a shared static constructor
class Foo
{
shared {
static this() // shared? static constructor
{
}
}
}
| Proposed | Website | |
| ImportDeclaration: | ImportDeclaration: | |
| import ImportList ; | import ImportList ; | |
| -+ | static import ImportList ; |
static is already covered by AttributeSpecifier. This is missing protection attributes, but these are also covered by the AttributeSpecifier. It's also unclear whether putting an import into a static {} block should also make the imports static.
static
{
import mod1; // static import?
import mod2;
}
| Proposed | Website | |
| = | ||
| ImportList: | ImportList: | |
| Import | Import | |
| ImportBindings | ImportBindings | |
| Import , ImportList | Import , ImportList | |
| Import: | Import: | |
| ModuleFullyQualifiedName | ModuleFullyQualifiedName | |
| ModuleAliasIdentifier = ModuleFullyQualifiedName | ModuleAliasIdentifier = ModuleFullyQualifiedName | |
| ImportBindings: | ImportBindings: | |
| Import : ImportBindList | Import : ImportBindList | |
| ImportBindList: | ImportBindList: | |
| ImportBind | ImportBind | |
| ImportBind , ImportBindList | ImportBind , ImportBindList | |
| ImportBind: | ImportBind: | |
| Identifier | Identifier | |
| Identifier = Identifier | Identifier = Identifier | |
| ModuleAliasIdentifier: | ModuleAliasIdentifier: | |
| Identifier | Identifier | |
| MixinDeclaration: | MixinDeclaration: | |
| mixin ( AssignExpression ) ; | mixin ( AssignExpression ) ; | |
| Declaration: | Declaration: | |
| alias Decl | alias Decl | |
| typedef Decl /* for legacy code */ | +- | |
| Decl | = | Decl |
| Decl: | Decl: | |
| StorageClasses Decl | StorageClasses Decl | |
| BasicType BasicTypes2opt Declarators ; | <> | BasicType Declarators ; |
| BasicType BasicTypes2opt Declarator FunctionBody | BasicType Declarator FunctionBody | |
| AutoDeclaration | = | AutoDeclaration |
The original grammar uses BasicTypes2 as part of Declarator in the Declarators, but this is not allowed in a list of variables.
| Proposed | Website | |
| Declarators: | Declarators: | |
| DeclaratorInitializer | DeclaratorInitializer | |
| DeclaratorInitializer , DeclaratorIdentifierList | DeclaratorInitializer , DeclaratorIdentifierList | |
| DeclaratorInitializer: | DeclaratorInitializer: | |
| Declarator | Declarator | |
| Declarator = Initializer | Declarator = Initializer | |
| DeclaratorIdentifierList: | DeclaratorIdentifierList: | |
| DeclaratorIdentifier | DeclaratorIdentifier | |
| DeclaratorIdentifier , DeclaratorIdentifierList | DeclaratorIdentifier , DeclaratorIdentifierList | |
| DeclaratorIdentifier: | DeclaratorIdentifier: | |
| Identifier | Identifier | |
| Identifier = Initializer | Identifier = Initializer | |
| BasicType: | BasicType: | |
| BasicTypeX | BasicTypeX | |
| . IdentifierList | <> | .IdentifierList |
| IdentifierList | = | IdentifierList |
| Typeof | Typeof | |
| Typeof . IdentifierList | Typeof . IdentifierList | |
| const ( Type ) | const( type ) | |
| immutable ( Type ) | immutable( type ) | |
| shared ( Type ) | shared( type ) | |
| inout ( Type ) | inout( type ) |
Missing space and case correction.
| Proposed | Website | |
| = | ||
| BasicTypeX: | BasicTypeX: | |
| bool | bool | |
| byte | byte | |
| ubyte | ubyte | |
| short | short | |
| ushort | ushort | |
| int | int | |
| uint | uint | |
| long | long | |
| ulong | ulong | |
| char | char | |
| wchar | wchar | |
| dchar | dchar | |
| float | float | |
| double | double | |
| real | real | |
| ifloat | ifloat | |
| idouble | idouble | |
| ireal | ireal | |
| cfloat | cfloat | |
| cdouble | cdouble | |
| creal | creal | |
| void | void | |
| BasicType2: | BasicType2: | |
| * | * | |
| [ ] | [ ] | |
| [ AssignExpression ] | [ AssignExpression ] | |
| [ AssignExpression .. AssignExpression ] | [ AssignExpression .. AssignExpression ] | |
| [ Type ] | [ Type ] | |
| delegate Parameters FunctionAttributesopt | delegate Parameters FunctionAttributesopt | |
| function Parameters FunctionAttributesopt | function Parameters FunctionAttributesopt | |
| BasicTypes2: | +- | |
| BasicType2 | ||
| BasicType2 BasicTypes2 | ||
| = | ||
| Declarator: | Declarator: | |
| <> | BasicType2opt Declarator DeclaratorSuffixesopt | |
| Identifier DeclaratorSuffixesopt | BasicType2opt Identifier DeclaratorSuffixesopt |
Allow multiple BasicType2 modifiers (see also Decl). Does it make sense to have multiple delegate/function suffixes?
| Proposed | Website | |
| = | ||
| DeclaratorSuffixes: | DeclaratorSuffixes: | |
| DeclaratorSuffix | DeclaratorSuffix | |
| DeclaratorSuffix DeclaratorSuffixes | DeclaratorSuffix DeclaratorSuffixes | |
| DeclaratorSuffix: | DeclaratorSuffix: | |
| [ ] | [ ] | |
| [ AssignExpression ] | [ AssignExpression ] | |
| [ Type ] | [ Type ] | |
| TemplateParameterListopt Parameters MemberFunctionAttributesopt Constraintopt | <> | TemplateParameterListopt Parameters MemberFunctionAttributesopt |
Optional constraint missing for function template declaration.
| Proposed | Website | |
| = | ||
| GlobalIdentifierList: | +- | |
| IdentifierList | ||
| . IdentifierList |
Almost evereywhere an IdentifierList is allowed, starting name lookup at global scope is also allowed.
| Proposed | Website | |
| = | ||
| IdentifierList: | IdentifierList: | |
| Identifier | Identifier | |
| Identifier . IdentifierList | Identifier . IdentifierList | |
| TemplateInstance | TemplateInstance | |
| TemplateInstance . IdentifierList | TemplateInstance . IdentifierList | |
| StorageClasses: | StorageClasses: | |
| StorageClass | StorageClass | |
| StorageClass StorageClasses | StorageClass StorageClasses | |
| StorageClass: | StorageClass: | |
| abstract | abstract | |
| auto | auto | |
| const | const | |
| deprecated | deprecated | |
| extern | extern | |
| final | final | |
| immutable | immutable | |
| inout | inout | |
| shared | shared | |
| nothrow | nothrow | |
| override | override | |
| pure | pure | |
| ref | <> | |
| scope | = | scope |
| static | static | |
| synchronized | synchronized | |
| __gshared | +- | |
| __thread |
Added missing storage types. I don't know whether "ref" should be here, though.
| Proposed | Website | |
| = | ||
| Type: | Type: | |
| BasicType | BasicType | |
| BasicType Declarator2 | BasicType Declarator2 | |
| Declarator2: | Declarator2: | |
| BasicTypes2 Declarator2 | <> | BasicType2 Declarator2 |
| ( Declarator2 ) | = | ( Declarator2 ) |
| ( Declarator2 ) DeclaratorSuffixes | ( Declarator2 ) DeclaratorSuffixes |
See Declarator.
| Proposed | Website | |
| +- | ||
| TypeWithModifier: | ||
| Type | ||
| const TypeWithModifier | ||
| immutable TypeWithModifier | ||
| inout TypeWithModifier | ||
| shared TypeWithModifier |
Needed by cast and TypeSpecification.
| Proposed | Website | |
| = | ||
| Parameters: | Parameters: | |
| ( ParameterList ) | ( ParameterList ) | |
| ( ) | ( ) | |
| ParameterList: | ParameterList: | |
| Parameter | Parameter | |
| Parameter , ParameterList | Parameter , ParameterList | |
| Parameter ... | Parameter ... | |
| ... | ... | |
| Parameter: | Parameter: | |
| InOutopt ParameterDeclarator DefaultInitializerExpressionopt | <> | Declarator |
| Declarator = DefaultInitializerExpression | ||
| ParameterDeclarator: | InOut Declarator | |
| StorageClasses_opt BasicType BasicTypes2_opt Declaratoropt | InOut Declarator = DefaultInitializerExpression | |
Parameters must have a type. Storage classes are used to implement types like "const int[]". Maybe TypeWithModifier could also be used here.
| Proposed | Website | |
| = | ||
| InOut: | InOut: | |
| in | in | |
| out | out | |
| ref | ref | |
| lazy | lazy | |
| scope | +- |
scope takes a special meaning here, but could also be considered as part of StorageClass.
| Proposed | Website | |
| = | ||
| FunctionAttributes: | FunctionAttributes: | |
| FunctionAttribute | FunctionAttribute | |
| FunctionAttribute FunctionAttributes | FunctionAttribute FunctionAttributes | |
| FunctionAttribute: | FunctionAttribute: | |
| nothrow | nothrow | |
| pure | pure | |
| MemberFunctionAttributes: | MemberFunctionAttributes: | |
| MemberFunctionAttribute | MemberFunctionAttribute | |
| MemberFunctionAttribute MemberFunctionAttributes | MemberFunctionAttribute MemberFunctionAttributes | |
| MemberFunctionAttribute: | MemberFunctionAttribute: | |
| const | const | |
| immutable | immutable | |
| inout | inout | |
| shared | shared | |
| FunctionAttribute | FunctionAttribute | |
| DefaultInitializerExpression: | DefaultInitializerExpression: | |
| = AssignExpression | <> | AssignExpression |
| __FILE__ | ||
| __LINE__ |
'=' added due to changed Parameter definition, __FILE__ and __LINE__ are also part of expressions.
| Proposed | Website | |
| = | ||
| Initializer: | Initializer: | |
| VoidInitializer | VoidInitializer | |
| NonVoidInitializer | NonVoidInitializer | |
| NonVoidInitializer: | NonVoidInitializer: | |
| AssignExpression | AssignExpression | |
| ArrayInitializer | ArrayInitializer | |
| StructInitializer | StructInitializer | |
| ArrayInitializer: | ArrayInitializer: | |
| <> | [ ] | |
| [ ArrayMemberInitializations ] | ||
| ArrayLiteral | ||
| ArrayMemberInitializations: | ||
| ArrayMemberInitialization | ||
| ArrayMemberInitialization , | ||
| ArrayMemberInitialization , ArrayMemberInitializations | ||
| ArrayMemberInitialization: | ||
| NonVoidInitializer | ||
| AssignExpression : NonVoidInitializer | ||
| StructInitializer: | = | StructInitializer: |
| <> | { } | |
| { StructMemberInitializers } | ||
| StructMemberInitializers: | ||
| StructLiteral | StructMemberInitializer | |
| StructMemberInitializer , | ||
| StructMemberInitializer , StructMemberInitializers | ||
| StructMemberInitializer: | ||
| NonVoidInitializer | ||
| Identifier : NonVoidInitializer |
A context free parser cannot really make sense of the literal in the initializer, so it might be good enough to parse these as part of the expression. StructInitializer is deprecated, but I moved into the expression as well. Would be nice, if the initializer would not be special-cased.
| Proposed | Website | |
| AutoDeclaration: | = | AutoDeclaration: |
| StorageClasses Identifier = AssignExpression ; | StorageClasses Identifier = AssignExpression ; | |
| Typeof: | Typeof: | |
| typeof ( Expression ) | typeof ( Expression ) | |
| typeof ( return ) | typeof ( return ) | |
| VoidInitializer: | VoidInitializer: | |
| void | void | |
| AttributeSpecifier: | AttributeSpecifier: | |
| Attribute : | Attribute : | |
| Attribute DeclarationBlock | Attribute DeclarationBlock | |
| Attribute: | Attribute: | |
| LinkageAttribute | LinkageAttribute | |
| AlignAttribute | AlignAttribute | |
| Pragma | Pragma | |
| deprecated | deprecated | |
| ProtectionAttribute | ProtectionAttribute | |
| static | static | |
| final | final | |
| override | override | |
| abstract | abstract | |
| const | const | |
| auto | auto | |
| scope | scope | |
| __gshared | __gshared | |
| shared | shared | |
| immutable | immutable | |
| inout | inout | |
| ref | +- | |
| extern | ||
| synchronized | ||
| __thread | ||
| @disable | = | @disable |
| @property | <> | |
| @safe | ||
| @system | ||
| @trusted |
Added missing attributes. This should probably be using StorageClass.
| Proposed | Website | |
| = | ||
| DeclarationBlock: | DeclarationBlock: | |
| DeclDef | DeclDef | |
| <> | { } | |
| { DeclDefsopt } | { DeclDefs } | |
| = | ||
| LinkageAttribute: | LinkageAttribute: | |
| -+ | extern | |
| extern ( LinkageType ) | = | extern ( LinkageType ) |
extern is not a linkage attibute (i.e. it does not affect calling convention and name mangling), but only where it is defined (a storage class?).
| Proposed | Website | |
| LinkageType: | LinkageType: | |
| C | C | |
| C ++ | <> | C++ |
| D | = | D |
| Windows | Windows | |
| Pascal | Pascal | |
| System | System | |
| AlignAttribute: | AlignAttribute: | |
| align | align | |
| align ( Integer ) | align ( Integer ) | |
| ProtectionAttribute: | ProtectionAttribute: | |
| private | private | |
| package | package | |
| protected | protected | |
| public | public | |
| export | export | |
| -+ | const | |
| override | ||
| static | ||
| auto | ||
| scope | ||
Stray grammer entries in the ddoc files. Should spaces and comments be allowed in "C++"?
| Proposed | Website | |
| Pragma: | = | Pragma: |
| pragma ( Identifier ) | pragma ( Identifier ) | |
| pragma ( Identifier , TemplateArgumentList ) | <> | pragma ( Identifier , ArgumentList ) |
| = |
pragma(msg) accepts both expression and types.
| Proposed | Website | |
| Expression: | Expression: | |
| CommaExpression | +- | |
| CommaExpression: | ||
| AssignExpression | = | AssignExpression |
| AssignExpression , CommaExpression | <> | AssignExpression , Expression |
| = | ||
| AssignExpression: | AssignExpression: | |
| ConditionalExpression | ConditionalExpression | |
| ConditionalExpression = AssignExpression | ConditionalExpression = AssignExpression | |
| ConditionalExpression += AssignExpression | ConditionalExpression += AssignExpression | |
| ConditionalExpression -= AssignExpression | ConditionalExpression -= AssignExpression | |
| ConditionalExpression *= AssignExpression | ConditionalExpression *= AssignExpression | |
| ConditionalExpression /= AssignExpression | ConditionalExpression /= AssignExpression | |
| ConditionalExpression %= AssignExpression | ConditionalExpression %= AssignExpression | |
| ConditionalExpression &= AssignExpression | ConditionalExpression &= AssignExpression | |
| ConditionalExpression |= AssignExpression | ConditionalExpression |= AssignExpression | |
| ConditionalExpression ^= AssignExpression | ConditionalExpression ^= AssignExpression | |
| ConditionalExpression ~= AssignExpression | ConditionalExpression ~= AssignExpression | |
| ConditionalExpression <<= AssignExpression | ConditionalExpression <<= AssignExpression | |
| ConditionalExpression >>= AssignExpression | ConditionalExpression >>= AssignExpression | |
| ConditionalExpression >>>= AssignExpression | ConditionalExpression >>>= AssignExpression | |
| ConditionalExpression ^^= AssignExpression | ConditionalExpression ^^= AssignExpression | |
| ConditionalExpression: | ConditionalExpression: | |
| OrOrExpression | OrOrExpression | |
| OrOrExpression ? Expression : ConditionalExpression | OrOrExpression ? Expression : ConditionalExpression | |
| OrOrExpression: | OrOrExpression: | |
| AndAndExpression | AndAndExpression | |
| OrOrExpression || AndAndExpression | OrOrExpression || AndAndExpression | |
| AndAndExpression: | AndAndExpression: | |
| OrExpression | OrExpression | |
| AndAndExpression && OrExpression | AndAndExpression && OrExpression | |
| CmpExpression | -+ | CmpExpression |
| AndAndExpression && CmpExpression | AndAndExpression && CmpExpression | |
| = | ||
| OrExpression: | OrExpression: | |
| XorExpression | XorExpression | |
| OrExpression | XorExpression | OrExpression | XorExpression | |
| XorExpression: | XorExpression: | |
| AndExpression | AndExpression | |
| XorExpression ^ AndExpression | XorExpression ^ AndExpression | |
| AndExpression: | AndExpression: | |
| ShiftExpression | <> | ShiftExpression |
| AndExpression & ShiftExpression | AndExpression & ShiftExpression |
| Proposed | Website | |
| = | ||
| CmpExpression: | CmpExpression: | |
| ShiftExpression | ShiftExpression | |
| EqualExpression | EqualExpression | |
| IdentityExpression | IdentityExpression | |
| RelExpression | RelExpression | |
| InExpression | InExpression | |
| EqualExpression: | EqualExpression: | |
| ShiftExpression == ShiftExpression | ShiftExpression == ShiftExpression | |
| ShiftExpression != ShiftExpression | ShiftExpression != ShiftExpression | |
| IdentityExpression: | IdentityExpression: | |
| ShiftExpression is ShiftExpression | ShiftExpression is ShiftExpression | |
| ShiftExpression !is ShiftExpression | ShiftExpression !is ShiftExpression | |
| RelExpression: | RelExpression: | |
| ShiftExpression < ShiftExpression | ShiftExpression < ShiftExpression | |
| ShiftExpression <= ShiftExpression | ShiftExpression <= ShiftExpression | |
| ShiftExpression > ShiftExpression | ShiftExpression > ShiftExpression | |
| ShiftExpression >= ShiftExpression | ShiftExpression >= ShiftExpression | |
| ShiftExpression !<>= ShiftExpression | ShiftExpression !<>= ShiftExpression | |
| ShiftExpression !<> ShiftExpression | ShiftExpression !<> ShiftExpression | |
| ShiftExpression <> ShiftExpression | ShiftExpression <> ShiftExpression | |
| ShiftExpression <>= ShiftExpression | ShiftExpression <>= ShiftExpression | |
| ShiftExpression !> ShiftExpression | ShiftExpression !> ShiftExpression | |
| ShiftExpression !>= ShiftExpression | ShiftExpression !>= ShiftExpression | |
| ShiftExpression !< ShiftExpression | ShiftExpression !< ShiftExpression | |
| ShiftExpression !<= ShiftExpression | ShiftExpression !<= ShiftExpression | |
| InExpression: | InExpression: | |
| ShiftExpression in ShiftExpression | ShiftExpression in ShiftExpression | |
| ShiftExpression !in ShiftExpression | ShiftExpression !in ShiftExpression |
Should !in and !is be single tokens? Right now you can put spaces and comments after the !.
| Proposed | Website | |
| ShiftExpression: | ShiftExpression: | |
| AddExpression | AddExpression | |
| ShiftExpression << AddExpression | ShiftExpression << AddExpression | |
| ShiftExpression >> AddExpression | ShiftExpression >> AddExpression | |
| ShiftExpression >>> AddExpression | ShiftExpression >>> AddExpression | |
| AddExpression: | AddExpression: | |
| MulExpression | MulExpression | |
| AddExpression + MulExpression | AddExpression + MulExpression | |
| AddExpression - MulExpression | AddExpression - MulExpression | |
| CatExpression | CatExpression | |
| CatExpression: | CatExpression: | |
| AddExpression ~ MulExpression | AddExpression ~ MulExpression | |
| MulExpression: | MulExpression: | |
| PowExpression | PowExpression | |
| MulExpression * PowExpression | MulExpression * PowExpression | |
| MulExpression / PowExpression | MulExpression / PowExpression | |
| MulExpression % PowExpression | MulExpression % PowExpression | |
| PowExpression: | PowExpression: | |
| UnaryExpression | UnaryExpression | |
| UnaryExpression ^^ PowExpression | UnaryExpression ^^ PowExpression | |
| UnaryExpression: | UnaryExpression: | |
| PostfixExpression | PostfixExpression | |
| & UnaryExpression | & UnaryExpression | |
| ++ UnaryExpression | ++ UnaryExpression | |
| -- UnaryExpression | -- UnaryExpression | |
| * UnaryExpression | * UnaryExpression | |
| - UnaryExpression | - UnaryExpression | |
| + UnaryExpression | + UnaryExpression | |
| ! UnaryExpression | ! UnaryExpression | |
| ~ UnaryExpression | ~ UnaryExpression | |
| -+ | ( Type ) . Identifier | |
| NewExpression | = | NewExpression |
| DeleteExpression | DeleteExpression | |
| CastExpression | CastExpression | |
| -+ | NewAnonClassExpression |
"(Type).Identifier" should be part of PostfixExpression to have the same precedence as BasicType.Identifier. NewAnonClassExpression is already covered by NewExpression.
| Proposed | Website | |
| = | ||
| NewExpression: | NewExpression: | |
| NewArguments Type [ AssignExpression ] | NewArguments Type [ AssignExpression ] | |
| NewArguments Type ( ArgumentList ) | NewArguments Type ( ArgumentList ) | |
| NewArguments Type | NewArguments Type | |
| NewArguments ClassArguments BaseClassesopt { DeclDefsopt } | <> | NewArguments ClassArguments BaseClasslistopt { DeclDefs } |
DeclDefs is never empty.
| Proposed | Website | |
| = | ||
| NewArguments: | NewArguments: | |
| new ( ArgumentList ) | new ( ArgumentList ) | |
| new ( ) | new ( ) | |
| new | new | |
| ClassArguments: | ClassArguments: | |
| class ( ArgumentList ) | class ( ArgumentList ) | |
| class ( ) | class ( ) | |
| class | class | |
| ArgumentList: | ArgumentList: | |
| AssignExpression | AssignExpression | |
| AssignExpression , | AssignExpression , | |
| AssignExpression , ArgumentList | AssignExpression , ArgumentList | |
| Arguments: | <> | |
| ( ) | ||
| ( ArgumentList ) |
Arguments used by PrimaryExpression and could simplify a few more rules.
| Proposed | Website | |
| = | ||
| DeleteExpression: | DeleteExpression: | |
| delete UnaryExpression | delete UnaryExpression | |
| -+ | ||
| CastExpression: | = | CastExpression: |
| cast ( TypeWithModifier ) UnaryExpression | <> | cast ( Type ) UnaryExpression |
| cast ( ) UnaryExpression | ||
| cast ( const ) UnaryExpression | ||
| cast ( const shared ) UnaryExpression | ||
| cast ( immutable ) UnaryExpression | ||
| cast ( inout ) UnaryExpression | ||
| cast ( inout shared ) UnaryExpression | ||
| cast ( shared ) UnaryExpression | ||
| cast ( shared const ) UnaryExpression | ||
| cast ( shared inout ) UnaryExpression |
Allow casting away or adding modifiers with/without type.
| Proposed | Website | |
| = | ||
| PostfixExpression: | PostfixExpression: | |
| PrimaryExpression | PrimaryExpression | |
| PostfixExpression . IdentifierOrTemplateInstance | <> | PostfixExpression . Identifier |
| PostfixExpression . NewExpression | = | PostfixExpression . NewExpression |
| PostfixExpression ++ | PostfixExpression ++ | |
| PostfixExpression -- | PostfixExpression -- | |
| PostfixExpression ( ) | PostfixExpression ( ) | |
| PostfixExpression ( ArgumentList ) | PostfixExpression ( ArgumentList ) | |
| IndexExpression | IndexExpression | |
| SliceExpression | SliceExpression |
Often a template instance can also be used instead of an identifier.
| Proposed | Website | |
| IndexExpression: | IndexExpression: | |
| PostfixExpression [ ArgumentList ] | PostfixExpression [ ArgumentList ] | |
| SliceExpression: | SliceExpression: | |
| PostfixExpression [ ] | PostfixExpression [ ] | |
| PostfixExpression [ AssignExpression .. AssignExpression ] | PostfixExpression [ AssignExpression .. AssignExpression ] | |
| PrimaryExpression: | PrimaryExpression: | |
| Identifier | Identifier | |
| . Identifier | <> | .Identifier |
| TemplateInstance | = | TemplateInstance |
| this | this | |
| super | super | |
| null | null | |
| true | true | |
| false | false | |
| $ | $ | |
| __FILE__ | __FILE__ | |
| __LINE__ | __LINE__ | |
| IntegerLiteral | IntegerLiteral | |
| FloatLiteral | FloatLiteral | |
| CharacterLiteral | CharacterLiteral | |
| StringLiterals | StringLiterals | |
| ArrayLiteral | ArrayLiteral | |
| AssocArrayLiteral | AssocArrayLiteral | |
| FunctionLiteral | FunctionLiteral | |
| StructLiteral // deprecated | +- | |
| AssertExpression | = | AssertExpression |
| MixinExpression | MixinExpression | |
| ImportExpression | ImportExpression | |
| BasicType . IdentifierOrTemplateInstance | <> | |
| Typeof . IdentifierOrTemplateInstance | ||
| ( Type ) . IdentifierOrTemplateInstance | ||
| BasicType Arguments | BasicType . Identifier | |
| Typeof Arguments | Typeof | |
| ( Type ) Arguments | ||
| TypeidExpression | = | TypeidExpression |
| IsExpression | IsExpression | |
| ( Expression ) | ( Expression ) | |
| TraitsExpression | TraitsExpression |
Added struct constructor syntax. Typeof on its own is a Type, not an expression.
| Proposed | Website | |
| StringLiterals: | StringLiterals: | |
| StringLiteral | StringLiteral | |
| StringLiterals StringLiteral | StringLiterals StringLiteral | |
| ArrayLiteral: | ArrayLiteral: | |
| [ ArgumentList ] | [ ArgumentList ] | |
| AssocArrayLiteral: | AssocArrayLiteral: | |
| [ KeyValuePairs ] | [ KeyValuePairs ] | |
| ArrayValueList: | <> | KeyValuePairs: |
| ArrayValue | KeyValuePair | |
| ArrayValue , ArrayValue | KeyValuePair , KeyValuePairs | |
| = | ||
| ArrayValue: | <> | KeyValuePair: |
| KeyExpression : ValueExpression | ||
| AssignExpression | KeyExpression: | |
| AssignExpression : AssignExpression | ConditionalExpression | |
| = | ||
| -+ | ValueExpression: | |
| ConditionalExpression |
It's not possible for the parser to distinguish a associative array from a dynamic/static array, because they all have the "expr : val" initializer syntax.
| Proposed | Website | |
| FunctionLiteral: | = | FunctionLiteral: |
| function Typeopt ParameterAttributesopt FunctionBody | <> | function Typeopt ParameterAttributes opt FunctionBody |
| delegate Typeopt ParameterAttributesopt FunctionBody | delegate Typeopt ParameterAttributes opt FunctionBody | |
| ParameterAttributes FunctionBody | = | ParameterAttributes FunctionBody |
| FunctionBody | FunctionBody | |
| ParameterAttributes: | ParameterAttributes: | |
| Parameters | Parameters | |
| Parameters FunctionAttributes | Parameters FunctionAttributes | |
| StructLiteral: | <> | |
| { ArrayValueList } |
| Proposed | Website | |
| = | ||
| AssertExpression: | AssertExpression: | |
| assert ( AssignExpression ) | assert ( AssignExpression ) | |
| assert ( AssignExpression , AssignExpression ) | assert ( AssignExpression , AssignExpression ) | |
| MixinExpression: | MixinExpression: | |
| mixin ( AssignExpression ) | mixin ( AssignExpression ) | |
| ImportExpression: | ImportExpression: | |
| import ( AssignExpression ) | import ( AssignExpression ) | |
| TypeidExpression: | TypeidExpression: | |
| typeid ( Type ) | typeid ( Type ) | |
| typeid ( Expression ) | typeid ( Expression ) | |
| IsExpression: | IsExpression: | |
| is ( Type ) | is ( Type ) | |
| is ( Type : TypeSpecialization ) | is ( Type : TypeSpecialization ) | |
| is ( Type == TypeSpecialization ) | is ( Type == TypeSpecialization ) | |
| is ( Type Identifier ) | is ( Type Identifier ) | |
| is ( Type Identifier : TypeSpecialization ) | is ( Type Identifier : TypeSpecialization ) | |
| is ( Type Identifier == TypeSpecialization ) | is ( Type Identifier == TypeSpecialization ) | |
| is ( Type Identifier : TypeSpecialization , TemplateParameterList ) | is ( Type Identifier : TypeSpecialization , TemplateParameterList ) | |
| is ( Type Identifier == TypeSpecialization , TemplateParameterList ) | is ( Type Identifier == TypeSpecialization , TemplateParameterList ) | |
| TypeSpecialization: | TypeSpecialization: | |
| TypeWithModifier | <> | Type |
| struct | = | struct |
| union | union | |
| class | class | |
| interface | interface | |
| enum | enum | |
| function | function | |
| delegate | delegate | |
| super | super | |
| const | const | |
| immutable | immutable | |
| inout | inout | |
| shared | shared | |
| return | return | |
TypeSpecialization can have type modifiers. If !is is a token to the lexer, it needs special treatment in the IsExpression.
| Proposed | Website | |
| = | ||
| TraitsExpression: | TraitsExpression: | |
| __traits ( TraitsKeyword , TraitsArguments ) | __traits ( TraitsKeyword , TraitsArguments ) | |
| TraitsKeyword: | TraitsKeyword: | |
| isAbstractClass | isAbstractClass | |
| isArithmetic | isArithmetic | |
| isAssociativeArray | isAssociativeArray | |
| isFinalClass | isFinalClass | |
| isFloating | isFloating | |
| isIntegral | isIntegral | |
| isScalar | isScalar | |
| isStaticArray | isStaticArray | |
| isUnsigned | isUnsigned | |
| isVirtualFunction | isVirtualFunction | |
| isAbstractFunction | isAbstractFunction | |
| isFinalFunction | isFinalFunction | |
| isStaticFunction | isStaticFunction | |
| isRef | isRef | |
| isOut | isOut | |
| isLazy | isLazy | |
| hasMember | hasMember | |
| identifier | identifier | |
| getMember | getMember | |
| getOverloads | getOverloads | |
| getVirtualFunctions | getVirtualFunctions | |
| classInstanceSize | classInstanceSize | |
| allMembers | allMembers | |
| derivedMembers | derivedMembers | |
| isSame | isSame | |
| compiles | compiles | |
| TraitsArguments: | TraitsArguments: | |
| TraitsArgument | TraitsArgument | |
| TraitsArgument , TraitsArguments | TraitsArgument , TraitsArguments | |
| TraitsArgument: | TraitsArgument: | |
| AssignExpression | AssignExpression | |
| Type | Type | |
| Statement: | ScopeStatement: | |
| ScopeStatement | +- | NonEmptyStatement |
| BlockStatement | ||
| ScopeStatement: | Statement: | |
| ; | = | ; |
| NonEmptyStatement | NonEmptyStatement | |
| ScopeBlockStatement | ScopeBlockStatement | |
| +- | ||
| ScopeBlockStatement: | ScopeBlockStatement: | |
| BlockStatement | BlockStatement | |
| ScopeNonEmptyStatement: | NonEmptyOrScopeBlockStatement: | |
| NonEmptyStatement | NonEmptyStatement | |
| BlockStatement | ScopeBlockStatement |
Tried to make naming clearer, but probably just added to the confusion here...
| Proposed | Website | |
| = | ||
| NoScopeNonEmptyStatement: | NoScopeNonEmptyStatement: | |
| NonEmptyStatement | NonEmptyStatement | |
| BlockStatement | BlockStatement | |
| NoScopeStatement: | NoScopeStatement: | |
| ; | ; | |
| NonEmptyStatement | NonEmptyStatement | |
| BlockStatement | BlockStatement |
| Proposed | Website | |
| = | ||
| NonEmptyStatement: | NonEmptyStatement: | |
| LabeledStatement | LabeledStatement | |
| ExpressionStatement | ExpressionStatement | |
| DeclarationStatement | DeclarationStatement | |
| IfStatement | IfStatement | |
| WhileStatement | WhileStatement | |
| DoStatement | DoStatement | |
| ForStatement | ForStatement | |
| ForeachStatement | ForeachStatement | |
| SwitchStatement | SwitchStatement | |
| FinalSwitchStatement | FinalSwitchStatement | |
| CaseStatement | CaseStatement | |
| CaseRangeStatement | CaseRangeStatement | |
| DefaultStatement | DefaultStatement | |
| ContinueStatement | ContinueStatement | |
| BreakStatement | BreakStatement | |
| ReturnStatement | ReturnStatement | |
| GotoStatement | GotoStatement | |
| WithStatement | WithStatement | |
| SynchronizedStatement | SynchronizedStatement | |
| TryStatement | TryStatement | |
| ScopeGuardStatement | ScopeGuardStatement | |
| ThrowStatement | ThrowStatement | |
| AsmStatement | AsmStatement | |
| PragmaStatement | PragmaStatement | |
| MixinStatement | MixinStatement | |
| ForeachRangeStatement | ForeachRangeStatement | |
| ConditionalStatement | ConditionalStatement | |
| StaticAssert | StaticAssert | |
| TemplateMixin | TemplateMixin | |
| EnumDeclaration | <> | |
| ClassDeclaration | ||
| InterfaceDeclaration | ||
| AggregateDeclaration | ||
| TemplateDeclaration |
Added missing declaration statements. Maybe these should be part of DeclarationStatement.
| Proposed | Website | |
| = | ||
| LabeledStatement: | LabeledStatement: | |
| Identifier : NoScopeStatement | Identifier : NoScopeStatement | |
| BlockStatement: | BlockStatement: | |
| { } | { } | |
| { StatementList } | { StatementList } | |
| StatementList: | StatementList: | |
| Statement | Statement | |
| Statement StatementList | Statement StatementList | |
| ExpressionStatement: | ExpressionStatement: | |
| Expression ; | Expression ; | |
| DeclarationStatement: | DeclarationStatement: | |
| Declaration | Declaration | |
| IfStatement: | IfStatement: | |
| if ( IfCondition ) ThenStatement | if ( IfCondition ) ThenStatement | |
| if ( IfCondition ) ThenStatement else ElseStatement | if ( IfCondition ) ThenStatement else ElseStatement | |
| IfCondition: | IfCondition: | |
| Expression | Expression | |
| auto Identifier = Expression | auto Identifier = Expression | |
| BasicType BasicTypes2opt Declarator = Expression | <> | Declarator = Expression |
| = | ||
| ThenStatement: | ThenStatement: | |
| ScopeNonEmptyStatement | <> | ScopeStatement |
| = | ||
| ElseStatement: | ElseStatement: | |
| ScopeNonEmptyStatement | <> | ScopeStatement |
Missing explicite type in IfCondition.
| Proposed | Website | |
| = | ||
| WhileStatement: | WhileStatement: | |
| while ( Expression ) ScopeNonEmptyStatement | <> | while ( Expression ) ScopeStatement |
| = | ||
| DoStatement: | DoStatement: | |
| do ScopeNonEmptyStatement while ( Expression ) ; | <> | do ScopeStatement while ( Expression ) |
Not forcing ';' is deprecated. Here is an example where it makes a difference:
if(true)
do {}
while(false); // will not parse with current grammar
else
{
}
| Proposed | Website | |
| = | ||
| ForStatement: | ForStatement: | |
| for ( Initialize Test ; Increment ) ScopeNonEmptyStatement | <> | for (Initialize Test ; Increment) ScopeStatement |
| Initialize: | = | Initialize: |
| ; | ; | |
| NoScopeNonEmptyStatement | NoScopeNonEmptyStatement | |
| Test: | Test: | |
| <> | empty | |
| Expressionopt | Expression | |
| = | ||
| Increment: | Increment: | |
| <> | empty | |
| Expressionopt | Expression |
| Proposed | Website | |
| = | ||
| ForeachStatement: | ForeachStatement: | |
| Foreach ( ForeachTypeList ; Aggregate ) NoScopeNonEmptyStatement | <> | Foreach (ForeachTypeList ; Aggregate) NoScopeNonEmptyStatement |
| = | ||
| Foreach: | Foreach: | |
| foreach | foreach | |
| foreach_reverse | foreach_reverse | |
| ForeachTypeList: | ForeachTypeList: | |
| ForeachType | ForeachType | |
| ForeachType , ForeachTypeList | ForeachType , ForeachTypeList | |
| ForeachType: | ForeachType: | |
| refopt Typeopt Identifier | <> | ref Type Identifier |
| Type Identifier | ||
| ref Identifier | ||
| Identifier |
| Proposed | Website | |
| = | ||
| Aggregate: | Aggregate: | |
| Expression | Expression | |
| SwitchStatement: | SwitchStatement: | |
| switch ( Expression ) ScopeNonEmptyStatement | <> | switch ( Expression ) ScopeStatement |
| = | ||
| +- | ||
| CaseStatement: | = | CaseStatement: |
| case ArgumentList : Statementopt | <> | case ArgumentList : Statement |
| = | ||
| CaseRangeStatement: | CaseRangeStatement: | |
| case FirstExp : .. case LastExp : Statementopt | <> | case FirstExp : .. case LastExp : Statement |
| = | ||
| FirstExp: | FirstExp: | |
| AssignExpression | AssignExpression | |
| LastExp: | LastExp: | |
| AssignExpression | AssignExpression | |
| DefaultStatement: | DefaultStatement: | |
| default : Statementopt | <> | default : Statement |
| Proposed | Website | |
| = | ||
| FinalSwitchStatement: | FinalSwitchStatement: | |
| final switch ( Expression ) ScopeNonEmptyStatement | <> | final switch ( Expression ) ScopeStatement |
| Proposed | Website | |
| = | ||
| ContinueStatement: | ContinueStatement: | |
| continue ; | <> | continue; |
| continue Identifier ; | = | continue Identifier ; |
| BreakStatement: | BreakStatement: | |
| break ; | <> | break; |
| break Identifier ; | = | break Identifier ; |
| ReturnStatement: | ReturnStatement: | |
| return ; | <> | return; |
| return Expression ; | = | return Expression ; |
| GotoStatement: | GotoStatement: | |
| goto Identifier ; | goto Identifier ; | |
| goto default ; | goto default ; | |
| goto case ; | goto case ; | |
| goto case Expression ; | goto case Expression ; | |
| WithStatement: | WithStatement: | |
| with ( Expression ) ScopeNonEmptyStatement | <> | with ( Expression ) ScopeStatement |
| with ( Symbol ) ScopeNonEmptyStatement | with ( Symbol ) ScopeStatement | |
| with ( TemplateInstance ) ScopeNonEmptyStatement | with ( TemplateInstance ) ScopeStatement | |
| = | ||
| SynchronizedStatement: | SynchronizedStatement: | |
| synchronized ScopeNonEmptyStatement | <> | synchronized ScopeStatement |
| synchronized ( Expression ) ScopeNonEmptyStatement | synchronized ( Expression ) ScopeStatement | |
| = | ||
| TryStatement: | TryStatement: | |
| try ScopeNonEmptyStatement Catches | <> | try ScopeStatement Catches |
| try ScopeNonEmptyStatement Catches FinallyStatement | try ScopeStatement Catches FinallyStatement | |
| try ScopeNonEmptyStatement FinallyStatement | try ScopeStatement FinallyStatement |
| Proposed | Website | |
| = | ||
| Catches: | Catches: | |
| LastCatch | LastCatch | |
| Catch | Catch | |
| Catch Catches | Catch Catches | |
| LastCatch: | LastCatch: | |
| catch NoScopeNonEmptyStatement | catch NoScopeNonEmptyStatement | |
| Catch: | Catch: | |
| catch ( CatchParameter ) NoScopeNonEmptyStatement | catch ( CatchParameter ) NoScopeNonEmptyStatement | |
| CatchParameter: | CatchParameter: | |
| BasicType Identifier | BasicType Identifier | |
| FinallyStatement: | FinallyStatement: | |
| finally NoScopeNonEmptyStatement | finally NoScopeNonEmptyStatement | |
| ThrowStatement: | ThrowStatement: | |
| throw Expression ; | throw Expression ; | |
| ScopeGuardStatement: | ScopeGuardStatement: | |
| scope ( exit ) ScopeNonEmptyStatement | <> | scope(exit) NonEmptyOrScopeBlockStatement |
| scope ( success ) ScopeNonEmptyStatement | scope(success) NonEmptyOrScopeBlockStatement | |
| scope ( failure ) ScopeNonEmptyStatement | scope(failure) NonEmptyOrScopeBlockStatement |
| Proposed | Website | |
| = | ||
| AsmStatement: | AsmStatement: | |
| asm { } | asm { } | |
| asm { AsmInstructionList } | asm { AsmInstructionList } | |
| AsmInstructionList: | AsmInstructionList: | |
| AsmInstruction ; | AsmInstruction ; | |
| AsmInstruction ; AsmInstructionList | AsmInstruction ; AsmInstructionList | |
| PragmaStatement: | PragmaStatement: | |
| Pragma NoScopeStatement | Pragma NoScopeStatement | |
| MixinStatement: | MixinStatement: | |
| mixin ( AssignExpression ) ; | mixin ( AssignExpression ) ; | |
| ForeachRangeStatement: | ForeachRangeStatement: | |
| Foreach ( ForeachType ; LwrExpression .. UprExpression ) ScopeNonEmptyStatement | <> | Foreach (ForeachType ; LwrExpression .. UprExpression ) ScopeStatement |
| Proposed | Website | |
| = | ||
| LwrExpression: | LwrExpression: | |
| Expression | Expression | |
| UprExpression: | UprExpression: | |
| Expression | Expression | |
| AggregateDeclaration: | AggregateDeclaration: | |
| struct Identifier StructBody | struct Identifier StructBody | |
| union Identifier StructBody | union Identifier StructBody | |
| struct Identifier ; | struct Identifier ; | |
| union Identifier ; | union Identifier ; | |
| StructTemplateDeclaration | StructTemplateDeclaration | |
| UnionTemplateDeclaration | UnionTemplateDeclaration | |
| StructBody: | StructBody: | |
| { DeclDefsopt } | <> | { } |
| { StructBodyDeclarations } | ||
| = | ||
| -+ | StructBodyDeclarations: | |
| StructBodyDeclaration | ||
| StructBodyDeclaration StructBodyDeclarations | ||
| StructBodyDeclaration: | ||
| Declaration | ||
| StaticConstructor | ||
| StaticDestructor | ||
| Invariant | ||
| UnitTest | ||
| StructAllocator | ||
| StructDeallocator | ||
| StructConstructor | ||
| StructPostblit | ||
| StructDestructor | ||
| AliasThis | ||
| StructAllocator: | ||
| ClassAllocator | ||
| StructDeallocator: | ||
| ClassDeallocator | ||
| Proposed | Website | |
| StructConstructor: | ||
| this ( ParameterList ) FunctionBody | ||
| StructPostblit: | ||
| this ( this ) FunctionBody | ||
| StructDestructor: | ||
| ~ this ( ) FunctionBody | ||
Merged with DeclDefs. DeclDefs.
| Proposed | Website | |
| ClassDeclaration: | = | ClassDeclaration: |
| class Identifier BaseClassListopt ClassBody | <> | class Identifier BaseClassList ClassBody |
| ClassTemplateDeclaration | = | ClassTemplateDeclaration |
| class Identifier ; | +- | |
| = | ||
| BaseClassList: | BaseClassList: | |
| -+ | Empty | |
| : SuperClass | = | : SuperClass |
| : SuperClass , InterfaceClasses | : SuperClass , InterfaceClasses |
Forward declaration allowed.allowed.
| Proposed | Website | |
| SuperClass: | SuperClass: | |
| GlobalIdentifierList | <> | Identifier |
| Protection GlobalIdentifierList | Protection Identifier | |
| = | ||
| InterfaceClasses: | InterfaceClasses: | |
| InterfaceClass | InterfaceClass | |
| InterfaceClass , InterfaceClasses | InterfaceClass , InterfaceClasses | |
| InterfaceClass: | InterfaceClass: | |
| GlobalIdentifierList | <> | Identifier |
| Protection GlobalIdentifierList | Protection Identifier |
Base classes are not limited to single identifeirs.
| Proposed | Website | |
| = | ||
| Protection: | Protection: | |
| private | private | |
| package | package | |
| public | public | |
| export | export | |
| ClassBody: | ClassBody: | |
| { } | { } | |
| { DeclDefsopt } | <>"><> | { ClassBodyDeclarations } |
| ClassBodyDeclarations:larations: | ||
| ClassBodyDeclaration | ||
| ClassBodyDeclaration ClassBodyDeclarations | ||
| = | ||
| -+ | ClassBodyDeclaration: | |
| Declaration | ||
| Constructor | ||
| Destructor | ||
| StaticConstructor | ||
| StaticDestructor | ||
| Invariant | ||
| UnitTest | ||
| ClassAllocator | ||
| ClassDeallocator |
ClassDeclarations merged with DeclDefs.
| Proposed | Website | |
| = | ||
| Constructor: | Constructor: | |
| this TemplateParametersopt Parameters MemberFunctionAttributesopt Constraintopt FunctionBody | <> | this Parameters FunctionBody |
| this ( this ) Constraintopt FunctionBody |
Constructors missing template functionality. Added postblit, maybe should be separated.
| Proposed | Website | |
| = | ||
| Destructor: | Destructor: | |
| ~ this ( ) FunctionBody | <> | ~this() FunctionBody |
| = | ||
| StaticConstructor: | StaticConstructor: | |
| static this ( ) FunctionBody | <> | static this() FunctionBody |
| = | ||
| StaticDestructor: | StaticDestructor: | |
| static ~ this ( ) FunctionBody | <> | static ~this() FunctionBody |
| = | ||
| SharedStaticConstructor: | SharedStaticConstructor: | |
| shared static this ( ) FunctionBody | <> | shared static this() FunctionBody |
| = | ||
| SharedStaticDestructor: | SharedStaticDestructor: | |
| shared static ~ this ( ) FunctionBody | <> | shared static ~this() FunctionBody |
| = |
Added spaces to separate tokens.
| Proposed | Website | |
| Invariant: | = | Invariant: |
| invariant ( ) BlockStatement | <> | invariant() BlockStatement |
| = | ||
| ClassAllocator: | ClassAllocator: | |
| new Parameters FunctionBody | new Parameters FunctionBody | |
| ClassDeallocator: | ClassDeallocator: | |
| delete Parameters FunctionBody | delete Parameters FunctionBody | |
| -+ | ||
| AliasThis: | = | AliasThis: |
| alias Identifier this; | alias Identifier this; | |
| -+ | ||
| NewAnonClassExpression: | ||
| new PerenArgumentListopt class PerenArgumentListopt SuperClassopt InterfaceClassesopt ClassBody | ||
| PerenArgumentList: | ||
| (ArgumentList) |
NewAnonClassExpression already part of NewExpression.
| Proposed | Website | |
| InterfaceDeclaration: | = | InterfaceDeclaration: |
| interface Identifier BaseInterfaceListopt InterfaceBody | <> | interface Identifier InterfaceBody |
| InterfaceTemplateDeclaration | = | InterfaceTemplateDeclaration |
| interface Identifier ; | +- | |
| = | ||
| BaseInterfaceList: | BaseInterfaceList: | |
| -+ | Empty | |
| : InterfaceClasses | = | : InterfaceClasses |
Baseclasses missing. Forward declaration allowed.
| Proposed | Website | |
| InterfaceBody: | InterfaceBody: | |
| { DeclDefsopt } | <> | { DeclDefs } |
Declarations can be empty.
| Proposed | Website | |
| EnumDeclaration: | = | EnumDeclaration: |
| enum EnumTag EnumBody | enum EnumTag EnumBody | |
| enum EnumBody | enum EnumBody | |
| enum EnumTag : EnumBaseType EnumBody | enum EnumTag : EnumBaseType EnumBody | |
| enum : EnumBaseType EnumBody | enum : EnumBaseType EnumBody | |
| enum EnumTag ; | +- | |
| enum EnumInitializer ; | ||
| enum Type EnumInitializers ; |
Allow forward declarations and declaration "enum a = 1;" and "enum int b = 2;"
| Proposed | Website | |
| = | ||
| EnumTag: | EnumTag: | |
| Identifier | Identifier | |
| EnumBaseType: | EnumBaseType: | |
| Type | Type | |
| EnumInitializers: | +- | |
| EnumInitializer | ||
| EnumInitializers , EnumInitializer | ||
| EnumInitializer: | ||
| Identifier = AssignExpression | ||
forward declaration might not be needed with proper forward reference handling anymore.
| Proposed | Website | |
| EnumBody: | = | EnumBody: |
| ; | ; | |
| { EnumMembers } | { EnumMembers } | |
| EnumMembers: | EnumMembers: | |
| EnumMember | EnumMember | |
| EnumMember , | EnumMember , | |
| EnumMember , EnumMembers | EnumMember , EnumMembers | |
| EnumMember: | EnumMember: | |
| Identifier | Identifier | |
| Identifier = AssignExpression | Identifier = AssignExpression | |
| Type Identifier = AssignExpression | Type Identifier = AssignExpression | |
| FunctionBody: | FunctionBody: | |
| BlockStatement | BlockStatement | |
| BodyStatement | BodyStatement | |
| InStatement BodyStatement | InStatement BodyStatement | |
| OutStatement BodyStatement | OutStatement BodyStatement | |
| InStatement OutStatement BodyStatement | InStatement OutStatement BodyStatement | |
| OutStatement InStatement BodyStatement | OutStatement InStatement BodyStatement | |
| InStatement: | InStatement: | |
| in BlockStatement | in BlockStatement | |
| OutStatement: | OutStatement: | |
| out BlockStatement | out BlockStatement | |
| out ( Identifier ) BlockStatement | out ( Identifier ) BlockStatement | |
| BodyStatement: | BodyStatement: | |
| body BlockStatement | body BlockStatement | |
body statement might be missing in interface contracts. Would it be disirable to allow different orderings in contracts: in-body-out or body-in-out?
| Proposed | Website | |
| ConditionalDeclaration: | ConditionalDeclaration: | |
| Condition DeclarationBlock | <> | Condition CCDeclarationBlock |
| Condition DeclarationBlock else DeclarationBlock | Condition CCDeclarationBlock else CCDeclarationBlock | |
| Condition : Declarations | ||
| CCDeclarationBlock: | ||
| Declaration | ||
| { Declarations } | ||
| { } | ||
| Declarations: | ||
| Declaration | ||
| Declaration Declarations |
The "Condition :" never existed and probably does not make good sense. The contents of a conditional block must not be limited to Declarations.
| Proposed | Website | |
| = | ||
| ConditionalStatement: | ConditionalStatement: | |
| Condition NoScopeNonEmptyStatement | Condition NoScopeNonEmptyStatement | |
| Condition NoScopeNonEmptyStatement else NoScopeNonEmptyStatement | Condition NoScopeNonEmptyStatement else NoScopeNonEmptyStatement | |
| Condition: | Condition: | |
| VersionCondition | VersionCondition | |
| DebugCondition | DebugCondition | |
| StaticIfCondition | StaticIfCondition | |
| VersionCondition: | VersionCondition: | |
| version ( Integer ) | version ( Integer ) | |
| version ( Identifier ) | version ( Identifier ) | |
| version ( unittest ) | version ( unittest ) | |
| VersionSpecification: | VersionSpecification: | |
| version = Identifier ; | version = Identifier ; | |
| version = Integer ; | version = Integer ; | |
| DebugCondition: | DebugCondition: | |
| debug | debug | |
| debug ( Integer ) | debug ( Integer ) | |
| debug ( Identifier ) | debug ( Identifier ) | |
| DebugSpecification: | DebugSpecification: | |
| debug = Identifier ; | debug = Identifier ; | |
| debug = Integer ; | debug = Integer ; | |
| StaticIfCondition: | StaticIfCondition: | |
| static if ( AssignExpression ) | static if ( AssignExpression ) | |
| StaticAssert: | StaticAssert: | |
| static assert ( AssignExpression ) ; | <> | static assert ( AssignExpression ); |
| static assert ( AssignExpression , AssignExpression ) ; | static assert ( AssignExpression , AssignExpression ); |
| Proposed | Website | |
| = | ||
| TemplateDeclaration: | TemplateDeclaration: | |
| template TemplateIdentifier ( TemplateParameterList ) Constraintopt { DeclDefs } | <> | template TemplateIdentifier ( TemplateParameterList ) Constraint { DeclDefs } |
| = | ||
| TemplateIdentifier: | TemplateIdentifier: | |
| Identifier | Identifier | |
| +- | ||
| TemplateParameters: | ||
| ( TemplateParameterList ) |
| Proposed | Website | |
| = | ||
| TemplateParameterList: | TemplateParameterList: | |
| TemplateParameter | TemplateParameter | |
| TemplateParameter , | TemplateParameter , | |
| TemplateParameter , TemplateParameterList | TemplateParameter , TemplateParameterList | |
| TemplateParameter: | TemplateParameter: | |
| TemplateTypeParameter | TemplateTypeParameter | |
| TemplateValueParameter | TemplateValueParameter | |
| TemplateAliasParameter | TemplateAliasParameter | |
| TemplateTupleParameter | TemplateTupleParameter | |
| TemplateThisParameter | TemplateThisParameter | |
| TemplateTupleParameter: | +- | TemplateTupleParameter: |
| Identifier ... | Identifier ... | |
| = | ||
| IdentifierOrTemplateInstance: | +- | |
| Identifier | ||
| TemplateInstance |
| Proposed | Website | |
| = | ||
| TemplateInstance: | TemplateInstance: | |
| TemplateIdentifier ! ( TemplateArgumentList ) | <> | TemplateIdentifier !( TemplateArgumentList ) |
| TemplateIdentifier ! TemplateSingleArgument | = | TemplateIdentifier ! TemplateSingleArgument |
| Proposed | Website | |
| TemplateArgumentList: | TemplateArgumentList: | |
| TemplateArgument | TemplateArgument | |
| TemplateArgument , | TemplateArgument , | |
| TemplateArgument , TemplateArgumentList | TemplateArgument , TemplateArgumentList | |
| TemplateArgument: | TemplateArgument: | |
| Type | Type | |
| AssignExpression | AssignExpression | |
| Symbol | <> | Symbol |
| = | ||
| Symbol: | Symbol: | |
| SymbolTail | SymbolTail | |
| . SymbolTail | . SymbolTail | |
SymbolTail identical to IdentifierList
| Proposed | Website | |
| +- | ||
| SymbolTail: | = | SymbolTail: |
| Identifier | Identifier | |
| Identifier . SymbolTail | Identifier . SymbolTail | |
| TemplateInstance | TemplateInstance | |
| TemplateInstance . SymbolTail | TemplateInstance . SymbolTail | |
| TemplateSingleArgument: | TemplateSingleArgument: | |
| Identifier | Identifier | |
| BasicTypeX | BasicTypeX | |
| CharacterLiteral | CharacterLiteral | |
| StringLiteral | StringLiteral | |
| IntegerLiteral | IntegerLiteral | |
| FloatLiteral | FloatLiteral | |
| true | true | |
| false | false | |
| null | null | |
| __FILE__ | __FILE__ | |
| __LINE__ | __LINE__ | |
| TemplateTypeParameter: | TemplateTypeParameter: | |
| Identifier | Identifier | |
| Identifier TemplateTypeParameterSpecialization | Identifier TemplateTypeParameterSpecialization | |
| Identifier TemplateTypeParameterDefault | Identifier TemplateTypeParameterDefault | |
| Identifier TemplateTypeParameterSpecialization TemplateTypeParameterDefault | Identifier TemplateTypeParameterSpecialization TemplateTypeParameterDefault | |
| TemplateTypeParameterSpecialization: | TemplateTypeParameterSpecialization: | |
| : Type | : Type | |
| TemplateTypeParameterDefault: | TemplateTypeParameterDefault: | |
| = Type | = Type | |
| -+ | TemplateThisParameter: | |
| this TemplateTypeParameter | ||
| TemplateValueParameter: | = | TemplateValueParameter: |
| TemplateValueDeclaration | <> | Declaration |
| TemplateValueDeclaration TemplateValueParameterSpecialization | Declaration TemplateValueParameterSpecialization | |
| TemplateValueDeclaration TemplateValueParameterDefault | Declaration TemplateValueParameterDefault | |
| TemplateValueDeclaration TemplateValueParameterSpecialization TemplateValueParameterDefault | Declaration TemplateValueParameterSpecialization TemplateValueParameterDefault | |
| = | ||
| TemplateValueDeclaration: | +- | |
| ParameterDeclarator /* without storage classes */ |
| Proposed | Website | |
| TemplateValueParameterSpecialization: | = | TemplateValueParameterSpecialization: |
| : ConditionalExpression | : ConditionalExpression | |
| TemplateValueParameterDefault: | TemplateValueParameterDefault: | |
| = __FILE__ /* already part of ConditionalExpression */ | <> | = __FILE__ |
| = __LINE__ /* already part of ConditionalExpression */ | = __LINE__ |
| Proposed | Website | |
| = ConditionalExpression | = | = ConditionalExpression |
| TemplateAliasParameter: | TemplateAliasParameter: | |
| alias Typeopt Identifier TemplateAliasParameterSpecializationopt TemplateAliasParameterDefaultopt | <> | alias Identifier TemplateAliasParameterSpecialization TemplateAliasParameterDefault |
| Proposed | Website | |
| = | ||
| TemplateAliasParameterSpecialization: | TemplateAliasParameterSpecialization: | |
| : Type | : Type | |
| TemplateAliasParameterDefault: | TemplateAliasParameterDefault: | |
| = TypeOrExpression | <> | = Type |
| = | ||
| -+ | ||
| Proposed | Website | |
| ClassTemplateDeclaration: | = | ClassTemplateDeclaration: |
| class Identifier ( TemplateParameterList ) Constraintopt BaseClassList_opt ClassBody | <> | class Identifier ( TemplateParameterList ) BaseClassList ClassBody |
| = | ||
| StructTemplateDeclaration: | StructTemplateDeclaration: | |
| struct Identifier ( TemplateParameterList ) Constraintopt StructBody | <> | struct Identifier ( TemplateParameterList ) Constraint StructBody |
| = | ||
| UnionTemplateDeclaration: | UnionTemplateDeclaration: | |
| union Identifier ( TemplateParameterList ) Constraintopt StructBody | <> | union Identifier ( TemplateParameterList ) Constraint StructBody |
| = | ||
| InterfaceTemplateDeclaration: | InterfaceTemplateDeclaration: | |
| interface Identifier ( TemplateParameterList ) Constraintopt BaseInterfaceList_opt InterfaceBody | <> | interface Identifier ( TemplateParameterList ) Constraint BaseInterfaceList InterfaceBody |
| = | ||
| TemplateMixinDeclaration: | TemplateMixinDeclaration: | |
| mixin template TemplateIdentifier ( TemplateParameterList ) Constraintopt { DeclDefs } | <> | mixin template TemplateIdentifier ( TemplateParameterList ) Constraint { DeclDefs } |
| = | ||
| Constraint: | Constraint: | |
| if ( ConstraintExpression ) | if ( ConstraintExpression ) | |
| ConstraintExpression: | ConstraintExpression: | |
| Expression | Expression |
Contraints are optional.
| Proposed | Website | |
| TemplateMixin:lateMixin: | = | TemplateMixin: |
| <> | mixin TemplateIdentifier ; | |
| mixin GlobalIdentifierList MixinIdentifieropt ; | mixin TemplateIdentifier MixinIdentifier ; | |
| mixin Typeof . IdentifierList MixinIdentifier_opt ; | mixin TemplateIdentifier !( TemplateArgumentList ) ; | |
| mixin TemplateIdentifier !( TemplateArgumentList ) MixinIdentifier ; | ||
| = | ||
| <> | MixinIdentifier: | |
| Identifier |
template mixin declarations can be referenced in other types and modules.
| Proposed | Website | |
| Unittest: | UnitTest: | |
| unittest BlockStatement | unittest FunctionBody |
No in/out/body for unittest.
| Proposed | Website | |
| = | ||
| AsmInstruction: | AsmInstruction: | |
| Identifier : AsmInstruction | Identifier : AsmInstruction | |
| align IntegerExpression | align IntegerExpression | |
| even | even | |
| naked | naked | |
| db Operands | db Operands | |
| ds Operands | ds Operands | |
| di Operands | di Operands | |
| dl Operands | dl Operands | |
| df Operands | df Operands | |
| dd Operands | dd Operands | |
| de Operands | de Operands | |
| Opcode | Opcode | |
| Opcode Operands | Opcode Operands | |
| Operands: | Operands: | |
| Operand | Operand | |
| Operand , Operands | Operand , Operands | |
| IntegerExpression: | IntegerExpression: | |
| IntegerLiteral | IntegerLiteral | |
| Identifier | Identifier | |
| Register: | Register: | |
| AL AH AX EAX | AL AH AX EAX | |
| BL BH BX EBX | BL BH BX EBX | |
| CL CH CX ECX | CL CH CX ECX | |
| DL DH DX EDX | DL DH DX EDX | |
| BP EBP | BP EBP | |
| SP ESP | SP ESP | |
| DI EDI | DI EDI | |
| SI ESI | SI ESI | |
| ES CS SS DS GS FS | ES CS SS DS GS FS | |
| CR0 CR2 CR3 CR4 | CR0 CR2 CR3 CR4 | |
| DR0 DR1 DR2 DR3 DR6 DR7 | DR0 DR1 DR2 DR3 DR6 DR7 | |
| TR3 TR4 TR5 TR6 TR7 | TR3 TR4 TR5 TR6 TR7 | |
| ST | ST | |
| ST(0) ST(1) ST(2) ST(3) ST(4) ST(5) ST(6) ST(7) | ST(0) ST(1) ST(2) ST(3) ST(4) ST(5) ST(6) ST(7) | |
| MM0 MM1 MM2 MM3 MM4 MM5 MM6 MM7 | MM0 MM1 MM2 MM3 MM4 MM5 MM6 MM7 | |
| XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 | XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 | |
| Operand: | Operand: | |
| AsmExp | AsmExp | |
| AsmExp: | AsmExp: | |
| AsmLogOrExp | AsmLogOrExp | |
| AsmLogOrExp ? AsmExp : AsmExp | AsmLogOrExp ? AsmExp : AsmExp | |
| AsmLogOrExp: | AsmLogOrExp: | |
| AsmLogAndExp | AsmLogAndExp | |
| AsmLogOrExp || AsmLogAndExp | <> | AsmLogAndExp || AsmLogAndExp |
| = | ||
| AsmLogAndExp: | AsmLogAndExp: | |
| AsmOrExp | AsmOrExp | |
| AsmLogAndExp && AsmOrExp | <> | AsmOrExp && AsmOrExp |
| = | ||
| AsmOrExp: | AsmOrExp: | |
| AsmXorExp | AsmXorExp | |
| AsmOrExp | AsmXorExp | <> | AsmXorExp | AsmXorExp |
| = | ||
| AsmXorExp: | AsmXorExp: | |
| AsmAndExp | AsmAndExp | |
| AsmXorExp ^ AsmAndExp | <> | AsmAndExp ^ AsmAndExp |
| = | ||
| AsmAndExp: | AsmAndExp: | |
| AsmEqualExp | AsmEqualExp | |
| AsmAndExp & AsmEqualExp | <> | AsmEqualExp & AsmEqualExp |
| = | ||
| AsmEqualExp: | AsmEqualExp: | |
| AsmRelExp | AsmRelExp | |
| AsmRelExp == AsmRelExp | AsmRelExp == AsmRelExp | |
| AsmRelExp != AsmRelExp | AsmRelExp != AsmRelExp | |
| AsmRelExp: | AsmRelExp: | |
| AsmShiftExp | AsmShiftExp | |
| AsmShiftExp < AsmShiftExp | AsmShiftExp < AsmShiftExp | |
| AsmShiftExp <= AsmShiftExp | AsmShiftExp <= AsmShiftExp | |
| AsmShiftExp > AsmShiftExp | AsmShiftExp > AsmShiftExp | |
| AsmShiftExp >= AsmShiftExp | AsmShiftExp >= AsmShiftExp | |
| AsmShiftExp: | AsmShiftExp: | |
| AsmAddExp | AsmAddExp | |
| AsmShiftExp << AsmAddExp | <> | AsmAddExp << AsmAddExp |
| AsmShiftExp >> AsmAddExp | AsmAddExp >> AsmAddExp | |
| AsmShiftExp >>> AsmAddExp | AsmAddExp >>> AsmAddExp | |
| = | ||
| AsmAddExp: | AsmAddExp: | |
| AsmMulExp | AsmMulExp | |
| AsmAddExp + AsmMulExp | <> | AsmMulExp + AsmMulExp |
| AsmAddExp - AsmMulExp | AsmMulExp - AsmMulExp | |
| = | ||
| AsmMulExp: | AsmMulExp: | |
| AsmBrExp | AsmBrExp | |
| AsmMulExp * AsmBrExp | <> | AsmBrExp * AsmBrExp |
| AsmMulExp / AsmBrExp | AsmBrExp / AsmBrExp | |
| AsmMulExp % AsmBrExp | AsmBrExp % AsmBrExp |
Expression not recursive, so "1 + 2 + 3" would not be allowed.
| Proposed | Website | |
| = | ||
| AsmBrExp: | AsmBrExp: | |
| AsmUnaExp | AsmUnaExp | |
| AsmBrExp [ AsmExp ] | AsmBrExp [ AsmExp ] | |
| AsmUnaExp: | AsmUnaExp: | |
| AsmTypePrefix AsmExp | AsmTypePrefix AsmExp | |
| offsetof AsmExp | offsetof AsmExp | |
| seg AsmExp | seg AsmExp | |
| + AsmUnaExp | + AsmUnaExp | |
| - AsmUnaExp | - AsmUnaExp | |
| ! AsmUnaExp | ! AsmUnaExp | |
| ~ AsmUnaExp | ~ AsmUnaExp | |
| AsmPrimaryExp | AsmPrimaryExp | |
| AsmPrimaryExp: | AsmPrimaryExp: | |
| IntegerLiteral | IntegerLiteral | |
| FloatLiteral | FloatLiteral | |
| __LOCAL_SIZE | __LOCAL_SIZE | |
| $ | $ | |
| Register | Register | |
| DotIdentifier | DotIdentifier | |
| DotIdentifier: | DotIdentifier: | |
| Identifier | Identifier | |
| Identifier . DotIdentifier | Identifier . DotIdentifier | |
| AsmTypePrefix: | AsmTypePrefix: | |
| near ptr | near ptr | |
| far ptr | far ptr | |
| byte ptr | byte ptr | |
| short ptr | short ptr | |
| int ptr | int ptr | |
| word ptr | word ptr | |
| dword ptr | dword ptr | |
| qword ptr | qword ptr | |
| float ptr | float ptr | |
| double ptr | double ptr | |
| real ptr | real ptr | |
| -+ |
