1
- // Based on grammar from dlang.org commit 9607293a246a0dc7a96417a84266cd0803675dcd
1
+ // Based on grammar from dlang.org commit 2c3088b5b6c1f35dfb3a0b2a37d4a0fe891d4350
2
2
3
3
import "grammardlex.ebnf" ;
4
4
SourceFile @start
@@ -288,30 +288,18 @@ PrimaryExpression @directUnwrap
288
288
| " ." IdentifierExpression
289
289
| <TemplateInstance
290
290
| " ." TemplateInstance
291
- | <ThisExpression
292
- | " super"
293
- | " null"
294
- | " true"
295
- | " false"
296
291
| " $"
297
- | IntegerLiteral
298
- | FloatLiteral
299
- | CharacterLiteral
300
- | <StringLiterals
301
- | <InterpolationExpressionSequence
302
- | <ArrayLiteral
303
- | <AssocArrayLiteral
304
- | <FunctionLiteralNoParen
292
+ | <LiteralExpression
305
293
| <AssertExpression
306
294
| <MixinExpression
307
295
| <ImportExpression
308
296
| <NewExpression
309
297
| FundamentalType " ." Identifier
310
- // | " (" Type " )" " ." Identifier
298
+ // | TypeCtor ? " (" Type " )" " ." Identifier
311
299
// | " (" Type " )" " ." TemplateInstance
312
300
// | FundamentalType " (" NamedArgumentList ? " )"
313
301
| TypeCtor " (" Type " )" " ." Identifier
314
- // | TypeCtor " (" Type " )" " (" NamedArgumentList ? " )"
302
+ // | TypeCtor ? " (" Type " )" " (" NamedArgumentList ? " )"
315
303
| <Typeof
316
304
| <TypeidExpression
317
305
| <IsExpression
@@ -320,6 +308,21 @@ PrimaryExpression @directUnwrap
320
308
| <Vector
321
309
| <PrimaryExpressionParen
322
310
;
311
+ LiteralExpression
312
+ = <ThisExpression
313
+ | " super"
314
+ | " null"
315
+ | " true"
316
+ | " false"
317
+ | IntegerLiteral
318
+ | FloatLiteral
319
+ | CharacterLiteral
320
+ | <StringLiterals
321
+ | <InterpolationExpressionSequence
322
+ | <ArrayLiteral
323
+ | <AssocArrayLiteral
324
+ | <FunctionLiteralNoParen
325
+ ;
323
326
PrimaryExpressionParen @backtrack
324
327
= <FunctionLiteralParen
325
328
| <ParenExpression
@@ -400,8 +403,10 @@ AssertExpression
400
403
= " assert" " (" AssertArguments " )"
401
404
;
402
405
AssertArguments
403
- = AssignExpression " ," ?
404
- | AssignExpression " ," AssignExpression " ," ?
406
+ = <AssignExpression
407
+ | AssignExpression " ,"
408
+ | AssignExpression " ," AssignExpression
409
+ | AssignExpression " ," AssignExpression " ,"
405
410
;
406
411
MixinExpression @directUnwrap
407
412
= <Mixin
@@ -560,6 +565,9 @@ NonVoidInitializer @backtrack
560
565
= <ArrayStructInitializer
561
566
| <AssignExpression
562
567
;
568
+ VoidInitializer
569
+ = " void"
570
+ ;
563
571
ArrayInitializer
564
572
= " [" ArrayMemberInitializations ? " ]"
565
573
;
@@ -619,9 +627,6 @@ AliasReassignment
619
627
| IdentifierExpression " =" FunctionLiteral " ;"
620
628
| IdentifierExpression " =" StorageClasses ? BasicType Parameters MemberFunctionAttributes ? " ;"
621
629
;
622
- VoidInitializer
623
- = " void"
624
- ;
625
630
AsmStatement
626
631
= " asm" FunctionAttributes ? " {" AsmInstructionList ? " }"
627
632
;
@@ -986,6 +991,7 @@ FunctionAttributeKwd @directUnwrap
986
991
;
987
992
AtAttribute @directUnwrap
988
993
= " @" Identifier >>" disable"
994
+ | " @" Identifier >>" __future"
989
995
| " @" Identifier >>" nogc"
990
996
| " @" Identifier >>" live"
991
997
| <Property
@@ -1149,10 +1155,18 @@ IfCondition @backtrack
1149
1155
| <Expression
1150
1156
;
1151
1157
IfConditionDecl
1152
- = Auto Identifier " =" Expression
1153
- | Scope Identifier " =" Expression
1154
- | TypeCtors Identifier " =" Expression
1155
- | TypeCtors ? PostfixType Declarator " =" Expression
1158
+ = IfConditionStorageClasses Identifier " =" Expression
1159
+ | IfConditionStorageClasses ? PostfixType Declarator " =" Expression
1160
+ ;
1161
+ IfConditionStorageClasses
1162
+ = <IfConditionStorageClass
1163
+ | IfConditionStorageClass IfConditionStorageClasses
1164
+ ;
1165
+ IfConditionStorageClass
1166
+ = " scope"
1167
+ | " auto"
1168
+ | " ref"
1169
+ | <TypeCtor
1156
1170
;
1157
1171
ThenStatement @directUnwrap
1158
1172
= <ScopeStatement
@@ -1548,15 +1562,14 @@ VariadicParameter
1548
1562
= VariadicArgumentsAttributes ? " ..."
1549
1563
;
1550
1564
Parameter
1565
+ = ParameterDeclaration
1566
+ | ParameterDeclaration " ..."
1567
+ | ParameterDeclaration " =" AssignExpression
1568
+ | ParameterDeclaration " =" AssignExpression " ..."
1569
+ ;
1570
+ ParameterDeclaration
1551
1571
= ParameterAttributes ? PostfixType Declarator
1552
- | ParameterAttributes ? PostfixType Declarator " ..."
1553
- | ParameterAttributes ? PostfixType Declarator " =" AssignExpression
1554
- | ParameterAttributes ? PostfixType Declarator " =" AssignExpression " ..."
1555
- | ParameterAttributes PostfixType
1556
- | ParameterAttributes ? PostfixType " =" AssignExpression
1557
- | ParameterAttributes ? PostfixType " =" AssignExpression " ..."
1558
- | PostfixType
1559
- | ParameterAttributes ? PostfixType " ..."
1572
+ | ParameterAttributes ? PostfixType
1560
1573
;
1561
1574
ParameterAttributes @array @regArray
1562
1575
= ParameterStorageClass
@@ -1662,13 +1675,13 @@ InOutStatement @directUnwrap
1662
1675
InContractExpression
1663
1676
= " in" " (" AssertArguments " )"
1664
1677
;
1678
+ InStatement
1679
+ = " in" BlockStatement
1680
+ ;
1665
1681
OutContractExpression
1666
1682
= " out" " (" " ;" AssertArguments " )"
1667
1683
| " out" " (" Identifier " ;" AssertArguments " )"
1668
1684
;
1669
- InStatement
1670
- = " in" BlockStatement
1671
- ;
1672
1685
OutStatement
1673
1686
= " out" BlockStatement
1674
1687
| " out" " (" Identifier " )" BlockStatement
0 commit comments