Added token rules. Fixed a few errors.
This commit is contained in:
parent
63a254b9cb
commit
461893dee3
447
D.g4
447
D.g4
|
@ -1,5 +1,187 @@
|
||||||
grammar D;
|
grammar D;
|
||||||
|
|
||||||
|
Assign: '=';
|
||||||
|
At: '@';
|
||||||
|
BitAnd: '&';
|
||||||
|
BitAndEqual: '&=';
|
||||||
|
BitOr: '|';
|
||||||
|
BitOrEqual: '|=';
|
||||||
|
CatEqual: '~=';
|
||||||
|
Colon: ':';
|
||||||
|
Comma: ',';
|
||||||
|
Decrement: '--';
|
||||||
|
Div: '/';
|
||||||
|
DivEqual: '/=';
|
||||||
|
Dollar: '$';
|
||||||
|
Dot: '.';
|
||||||
|
Equal: '==';
|
||||||
|
GoesTo: '=>';
|
||||||
|
Greater: '>';
|
||||||
|
GreaterEqual: '>=';
|
||||||
|
Hash: '#';
|
||||||
|
Increment: '++';
|
||||||
|
LBrace: '{';
|
||||||
|
LBracket: '[';
|
||||||
|
Less: '<';
|
||||||
|
LessEqual: '<=';
|
||||||
|
LessEqualGreater: '<>=';
|
||||||
|
LessOrGreater: '<>';
|
||||||
|
LogicAnd: '&&';
|
||||||
|
LogicOr: '||';
|
||||||
|
LParen: '(';
|
||||||
|
Minus: '-';
|
||||||
|
MinusEqual: '-=';
|
||||||
|
Mod: '%';
|
||||||
|
ModEqual: '%=';
|
||||||
|
MulEqual: '*=';
|
||||||
|
Not: '!';
|
||||||
|
NotEqual: '!=';
|
||||||
|
NotGreater: '!>';
|
||||||
|
NotGreaterEqual: '!>=';
|
||||||
|
NotLess: '!<';
|
||||||
|
NotLessEqual: '!<=';
|
||||||
|
NotLessEqualGreater: '!<>';
|
||||||
|
Plus: '+';
|
||||||
|
PlusEqual: '+=';
|
||||||
|
Pow: '^^';
|
||||||
|
PowEqual: '^^=';
|
||||||
|
RBrace: '}';
|
||||||
|
RBracket: ']';
|
||||||
|
RParen: ')';
|
||||||
|
Semicolon: ';';
|
||||||
|
ShiftLeft: '<<';
|
||||||
|
ShiftLeftEqual: '<<=';
|
||||||
|
ShiftRight: '>>';
|
||||||
|
ShiftRightEqual: '>>=';
|
||||||
|
Slice: '..';
|
||||||
|
Star: '*';
|
||||||
|
Ternary: '?';
|
||||||
|
Tilde: '~';
|
||||||
|
Unordered: '!<>=';
|
||||||
|
UnsignedShiftRight: '>>>';
|
||||||
|
UnsignedShiftRightEqual: '>>>=';
|
||||||
|
Vararg: '...';
|
||||||
|
Xor: '^';
|
||||||
|
XorEqual: '^=';
|
||||||
|
Bool: 'bool';
|
||||||
|
Byte: 'byte';
|
||||||
|
Cdouble: 'cdouble';
|
||||||
|
Cent: 'cent';
|
||||||
|
Cfloat: 'cfloat';
|
||||||
|
Char: 'char';
|
||||||
|
Creal: 'creal';
|
||||||
|
Dchar: 'dchar';
|
||||||
|
Double: 'double';
|
||||||
|
Float: 'float';
|
||||||
|
Function: 'function';
|
||||||
|
Idouble: 'idouble';
|
||||||
|
Ifloat: 'ifloat';
|
||||||
|
Int: 'int';
|
||||||
|
Ireal: 'ireal';
|
||||||
|
Long: 'long';
|
||||||
|
Real: 'real';
|
||||||
|
Short: 'short';
|
||||||
|
Ubyte: 'ubyte';
|
||||||
|
Ucent: 'ucent';
|
||||||
|
Uint: 'uint';
|
||||||
|
Ulong: 'ulong';
|
||||||
|
Ushort: 'ushort';
|
||||||
|
Void: 'void';
|
||||||
|
Wchar: 'wchar';
|
||||||
|
Align: 'align';
|
||||||
|
Deprecated: 'deprecated';
|
||||||
|
Extern: 'extern';
|
||||||
|
Pragma: 'pragma';
|
||||||
|
Export: 'export';
|
||||||
|
Package: 'package';
|
||||||
|
Private: 'private';
|
||||||
|
Protected: 'protected';
|
||||||
|
Public: 'public';
|
||||||
|
Abstract: 'abstract';
|
||||||
|
Auto: 'auto';
|
||||||
|
Const: 'const';
|
||||||
|
Final: 'final';
|
||||||
|
Gshared: '__gshared';
|
||||||
|
Immutable: 'immutable';
|
||||||
|
Inout: 'inout';
|
||||||
|
Scope: 'scope';
|
||||||
|
Shared: 'shared';
|
||||||
|
Static: 'static';
|
||||||
|
Synchronized: 'synchronized';
|
||||||
|
Alias: 'alias';
|
||||||
|
Asm: 'asm';
|
||||||
|
Assert: 'assert';
|
||||||
|
Body: 'body';
|
||||||
|
Break: 'break';
|
||||||
|
Case: 'case';
|
||||||
|
Cast: 'cast';
|
||||||
|
Catch: 'catch';
|
||||||
|
Class: 'class';
|
||||||
|
Continue: 'continue';
|
||||||
|
Debug: 'debug';
|
||||||
|
Default: 'default';
|
||||||
|
Delegate: 'delegate';
|
||||||
|
Delete: 'delete';
|
||||||
|
Do: 'do';
|
||||||
|
Else: 'else';
|
||||||
|
Enum: 'enum';
|
||||||
|
False: 'false';
|
||||||
|
Finally: 'finally';
|
||||||
|
Foreach: 'foreach';
|
||||||
|
Foreach_reverse: 'foreach_reverse';
|
||||||
|
For: 'for';
|
||||||
|
Goto: 'goto';
|
||||||
|
If: 'if';
|
||||||
|
Import: 'import';
|
||||||
|
In: 'in';
|
||||||
|
Interface: 'interface';
|
||||||
|
Invariant: 'invariant';
|
||||||
|
Is: 'is';
|
||||||
|
Lazy: 'lazy';
|
||||||
|
Macro: 'macro';
|
||||||
|
Mixin: 'mixin';
|
||||||
|
Module: 'module';
|
||||||
|
New: 'new';
|
||||||
|
Nothrow: 'nothrow';
|
||||||
|
Null: 'null';
|
||||||
|
Out: 'out';
|
||||||
|
Override: 'override';
|
||||||
|
Pure: 'pure';
|
||||||
|
Ref: 'ref';
|
||||||
|
Return: 'return';
|
||||||
|
Struct: 'struct';
|
||||||
|
Super: 'super';
|
||||||
|
Switch: 'switch';
|
||||||
|
Template: 'template';
|
||||||
|
This: 'this';
|
||||||
|
Throw: 'throw';
|
||||||
|
True: 'true';
|
||||||
|
Try: 'try';
|
||||||
|
Typedef: 'typedef';
|
||||||
|
Typeid: 'typeid';
|
||||||
|
Typeof: 'typeof';
|
||||||
|
Union: 'union';
|
||||||
|
Unittest: 'unittest';
|
||||||
|
Version: 'version';
|
||||||
|
Volatile: 'volatile';
|
||||||
|
While: 'while';
|
||||||
|
With: 'with';
|
||||||
|
|
||||||
|
SpecialDate: '__DATE__';
|
||||||
|
SpecialEof: '__EOF__';
|
||||||
|
SpecialTime: '__TIME__';
|
||||||
|
Specialimestamp: '__TIMESTAMP__';
|
||||||
|
SpecialVendor: '__VENDOR__';
|
||||||
|
SpecialVersion: '__VERSION__';
|
||||||
|
SpecialFile: '__FILE__';
|
||||||
|
SpecialLine: '__LINE__';
|
||||||
|
SpecialModule: '__MODULE__';
|
||||||
|
SpecialFunction: '__FUNCTION__';
|
||||||
|
SpecialPrettyFunction: '__PRETTY_FUNCTION__';
|
||||||
|
Traits: '__traits';
|
||||||
|
Parameters: '__parameters';
|
||||||
|
Vector: '__vector';
|
||||||
|
|
||||||
Whitespace: [\u0020\u0009\u000b\u000c\u000a\u000d]+ -> skip;
|
Whitespace: [\u0020\u0009\u000b\u000c\u000a\u000d]+ -> skip;
|
||||||
fragment EndOfLine : '\u000d' | '\u000a' | '\u000d' '\u000a' | '\u2028' | '\u2029';
|
fragment EndOfLine : '\u000d' | '\u000a' | '\u000d' '\u000a' | '\u2028' | '\u2029';
|
||||||
|
|
||||||
|
@ -54,8 +236,8 @@ fragment DecimalInteger: DecimalDigit (DecimalDigit | '_')*;
|
||||||
fragment BinaryInteger: ('0b' | '0B') BinDigit (BinDigit | '_')*;
|
fragment BinaryInteger: ('0b' | '0B') BinDigit (BinDigit | '_')*;
|
||||||
fragment HexadecimalInteger: ('0x' | '0X') HexDigit (HexDigit | '_')*;
|
fragment HexadecimalInteger: ('0x' | '0X') HexDigit (HexDigit | '_')*;
|
||||||
|
|
||||||
FloatLiteral: (Float FloatSuffix?) | (Integer (FloatSuffix | RealSuffix)? ImaginarySuffix);
|
FloatLiteral: (FloatOption FloatSuffix?) | (Integer (FloatSuffix | RealSuffix)? ImaginarySuffix);
|
||||||
fragment Float: DecimalFloat | HexFloat;
|
fragment FloatOption: DecimalFloat | HexFloat;
|
||||||
fragment DecimalFloat: (DecimalInteger '.' DecimalDigit*);
|
fragment DecimalFloat: (DecimalInteger '.' DecimalDigit*);
|
||||||
fragment DecimalExponent: ('e' | 'E' | 'e+' | 'E+' | 'e-' | 'E-') DecimalInteger;
|
fragment DecimalExponent: ('e' | 'E' | 'e+' | 'E+' | 'e-' | 'E-') DecimalInteger;
|
||||||
fragment FloatSuffix: 'F' | 'f';
|
fragment FloatSuffix: 'F' | 'f';
|
||||||
|
@ -72,42 +254,15 @@ module: moduleDeclaration? declaration*
|
||||||
moduleDeclaration: 'module' identifierChain ';'
|
moduleDeclaration: 'module' identifierChain ';'
|
||||||
;
|
;
|
||||||
|
|
||||||
importDeclaration: 'static'? 'import' importList ';'
|
|
||||||
;
|
|
||||||
|
|
||||||
importList: singleImport (',' importList)?
|
|
||||||
| importBindings
|
|
||||||
;
|
|
||||||
|
|
||||||
singleImport: (Identifier '=')? identifierChain
|
|
||||||
;
|
|
||||||
|
|
||||||
importBindings: singleImport ':' importbindlist
|
|
||||||
;
|
|
||||||
|
|
||||||
importbindlist: importBind (',' importbindlist)?
|
|
||||||
;
|
|
||||||
|
|
||||||
importBind: Identifier ('=' Identifier)?
|
|
||||||
;
|
|
||||||
|
|
||||||
declarationsAndStatements: (declaration | statement)+
|
|
||||||
;
|
|
||||||
|
|
||||||
declaration: attributedDeclaration
|
declaration: attributedDeclaration
|
||||||
| importDeclaration
|
| importDeclaration
|
||||||
| functionDeclaration
|
| functionDeclaration
|
||||||
| functionTemplateDeclaration
|
|
||||||
| variableDeclaration
|
| variableDeclaration
|
||||||
| aliasThisDeclaration
|
| aliasThisDeclaration
|
||||||
| structDeclaration
|
| structDeclaration
|
||||||
| structTemplateDeclaration
|
|
||||||
| classDeclaration
|
| classDeclaration
|
||||||
| classTemplateDeclaration
|
|
||||||
| interfaceDeclaration
|
| interfaceDeclaration
|
||||||
| interfaceTemplateDeclaration
|
|
||||||
| unionDeclaration
|
| unionDeclaration
|
||||||
| unionTemplateDeclaration
|
|
||||||
| aliasDeclaration
|
| aliasDeclaration
|
||||||
| mixinDeclaration
|
| mixinDeclaration
|
||||||
| unittest
|
| unittest
|
||||||
|
@ -118,28 +273,41 @@ declaration: attributedDeclaration
|
||||||
| sharedStaticConstructor
|
| sharedStaticConstructor
|
||||||
;
|
;
|
||||||
|
|
||||||
|
importDeclaration: 'static'? 'import' importList ';'
|
||||||
|
;
|
||||||
|
|
||||||
|
importList: singleImport (',' importList)?
|
||||||
|
| importBindings
|
||||||
|
;
|
||||||
|
|
||||||
|
singleImport: (Identifier '=')? identifierChain
|
||||||
|
;
|
||||||
|
|
||||||
|
importBindings: singleImport ':' importBindList
|
||||||
|
;
|
||||||
|
|
||||||
|
importBindList: importBind (',' importBind)?
|
||||||
|
;
|
||||||
|
|
||||||
|
importBind: Identifier ('=' Identifier)?
|
||||||
|
;
|
||||||
|
|
||||||
|
aliasThisDeclaration: 'alias' Identifier 'this' ';'
|
||||||
|
;
|
||||||
|
|
||||||
|
structDeclaration: 'struct' Identifier (templateParameters constraint? structBody | (structBody | ';'))
|
||||||
|
;
|
||||||
|
|
||||||
templateParameters: '(' templateParameterList? ')'
|
templateParameters: '(' templateParameterList? ')'
|
||||||
;
|
;
|
||||||
|
|
||||||
constraint: 'if' '(' expression ')'
|
constraint: 'if' '(' expression ')'
|
||||||
;
|
;
|
||||||
|
|
||||||
aliasThisDeclaration: 'alias' Identifier 'this' ';'
|
|
||||||
;
|
|
||||||
|
|
||||||
structDeclaration: 'struct' Identifier (structBody | ';')
|
|
||||||
;
|
|
||||||
|
|
||||||
structTemplateDeclaration: 'struct' Identifier templateParameters constraint? structBody
|
|
||||||
;
|
|
||||||
|
|
||||||
structBody: '{' declaration* '}'
|
structBody: '{' declaration* '}'
|
||||||
;
|
;
|
||||||
|
|
||||||
classDeclaration: 'class' Identifier (':' identifierList )? classBody
|
classDeclaration: 'class' Identifier (templateParameters constraint?)? (':' identifierList )? classBody
|
||||||
;
|
|
||||||
|
|
||||||
classTemplateDeclaration: 'class' Identifier templateParameters constraint? classBody
|
|
||||||
;
|
;
|
||||||
|
|
||||||
classBody: '{' (declaration | invariant)* '}'
|
classBody: '{' (declaration | invariant)* '}'
|
||||||
|
@ -149,16 +317,10 @@ statement: ';'
|
||||||
| nonemptyStatement
|
| nonemptyStatement
|
||||||
;
|
;
|
||||||
|
|
||||||
interfaceDeclaration: 'interface' Identifier (':' identifierList)? structBody
|
interfaceDeclaration: 'interface' Identifier (templateParameters constraint?)? (':' identifierList)? structBody
|
||||||
;
|
;
|
||||||
|
|
||||||
interfaceTemplateDeclaration: 'interface' Identifier templateParameters constraint? (':' identifierList)? structBody
|
unionDeclaration: 'union' Identifier ((templateParameters constraint? structBody)? | (structBody | ';'))
|
||||||
;
|
|
||||||
|
|
||||||
unionDeclaration: 'union' Identifier (structBody | ';')
|
|
||||||
;
|
|
||||||
|
|
||||||
unionTemplateDeclaration: 'union' Identifier parameters constraint? structBody
|
|
||||||
;
|
;
|
||||||
|
|
||||||
nonemptyStatement: nonEmptyStatementNoCaseNoDefault
|
nonemptyStatement: nonEmptyStatementNoCaseNoDefault
|
||||||
|
@ -484,78 +646,20 @@ initialize: ';'
|
||||||
foreachStatement: ('foreach' | 'foreach_reverse') '(' foreachTypeList ';' expression ')' nonEmptyStatementNoCaseNoDefault
|
foreachStatement: ('foreach' | 'foreach_reverse') '(' foreachTypeList ';' expression ')' nonEmptyStatementNoCaseNoDefault
|
||||||
;
|
;
|
||||||
|
|
||||||
foreachTypeList: foreachType
|
foreachTypeList: foreachType (',' foreachType)*
|
||||||
| foreachType ',' foreachTypeList
|
|
||||||
;
|
;
|
||||||
|
|
||||||
foreachType: 'ref'? type? Identifier
|
foreachType: 'ref'? type? Identifier
|
||||||
;
|
;
|
||||||
|
|
||||||
expression: assignExpression
|
expression: assignExpression (',' assignExpression)*
|
||||||
| assignExpression ',' expression
|
|
||||||
;
|
;
|
||||||
|
|
||||||
identifierOrTemplateInstance: Identifier
|
identifierOrTemplateInstance: Identifier
|
||||||
| templateInstance
|
| templateInstance
|
||||||
;
|
;
|
||||||
|
|
||||||
templateInstance: Identifier '!' (Identifier | '(' identifierList? ')')
|
templateInstance: Identifier templateArguments
|
||||||
;
|
|
||||||
|
|
||||||
unaryExpression: '&' unaryExpression
|
|
||||||
| '!' unaryExpression
|
|
||||||
| '*' unaryExpression
|
|
||||||
| '+' unaryExpression
|
|
||||||
| '-' unaryExpression
|
|
||||||
| '~' unaryExpression
|
|
||||||
| preIncDecExpression
|
|
||||||
| newExpression
|
|
||||||
| deleteExpression
|
|
||||||
| castExpression
|
|
||||||
| primaryExpression
|
|
||||||
/*| postIncDecExpression*/
|
|
||||||
| unaryExpression ('++'| '--')
|
|
||||||
| unaryExpression '[' ']'
|
|
||||||
| unaryExpression '[' argumentList ']'
|
|
||||||
| unaryExpression '[' assignExpression '..' assignExpression ']'
|
|
||||||
| unaryExpression '.' identifierOrTemplateInstance
|
|
||||||
;
|
|
||||||
|
|
||||||
powExpression: unaryExpression
|
|
||||||
| unaryExpression '^^' powExpression
|
|
||||||
;
|
|
||||||
|
|
||||||
postIncDecExpression: unaryExpression ('++' | '--')
|
|
||||||
;
|
|
||||||
|
|
||||||
preIncDecExpression: ('++' | '--') unaryExpression
|
|
||||||
;
|
|
||||||
|
|
||||||
primaryExpression: identifierOrTemplateInstance
|
|
||||||
| '.' identifierOrTemplateInstance
|
|
||||||
| type '.' Identifier
|
|
||||||
| typeofExpression
|
|
||||||
| typeidExpression
|
|
||||||
| 'this'
|
|
||||||
| 'super'
|
|
||||||
| 'null'
|
|
||||||
| 'true'
|
|
||||||
| 'false'
|
|
||||||
| '__FILE__'
|
|
||||||
| '__MODULE__'
|
|
||||||
| '__LINE__'
|
|
||||||
| '__FUNCTION__'
|
|
||||||
| '__PRETTY_FUNCTION__'
|
|
||||||
| IntegerLiteral
|
|
||||||
| FloatLiteral
|
|
||||||
| StringLiteral
|
|
||||||
| CharacterLiteral
|
|
||||||
| arrayLiteral
|
|
||||||
| assocArrayLiteral
|
|
||||||
| '(' expression ')'
|
|
||||||
| isExpression
|
|
||||||
| lambdaExpression
|
|
||||||
| traitsExpression
|
|
||||||
;
|
;
|
||||||
|
|
||||||
typeofExpression: 'typeof' '(' (expression | 'return') ')'
|
typeofExpression: 'typeof' '(' (expression | 'return') ')'
|
||||||
|
@ -578,19 +682,10 @@ templateParameter: templateTypeParameter
|
||||||
| templateThisParameter
|
| templateThisParameter
|
||||||
;
|
;
|
||||||
|
|
||||||
templateTypeParameter: Identifier templateTypeParameterSpecialization? templateTypeParameterDefault?
|
templateTypeParameter: Identifier (':' type)? ('=' type)?
|
||||||
;
|
;
|
||||||
|
|
||||||
templateTypeParameterSpecialization: ':' type
|
templateValueParameter: type Identifier (':' expression)? templateValueParameterDefault?
|
||||||
;
|
|
||||||
|
|
||||||
templateTypeParameterDefault: '=' type
|
|
||||||
;
|
|
||||||
|
|
||||||
templateValueParameter: type Identifier templateValueParameterSpecialization? templateValueParameterDefault?
|
|
||||||
;
|
|
||||||
|
|
||||||
templateValueParameterSpecialization: ':' expression
|
|
||||||
;
|
;
|
||||||
|
|
||||||
templateValueParameterDefault: '=' ('__FILE__' | '__MODULE__' | '__LINE__' | '__FUNCTION__' | '__PRETTY_FUNCTION__' | assignExpression)
|
templateValueParameterDefault: '=' ('__FILE__' | '__MODULE__' | '__LINE__' | '__FUNCTION__' | '__PRETTY_FUNCTION__' | assignExpression)
|
||||||
|
@ -719,25 +814,11 @@ cmpExpression: shiftExpression
|
||||||
|
|
||||||
equalExpression: shiftExpression ('==' | '!=') shiftExpression;
|
equalExpression: shiftExpression ('==' | '!=') shiftExpression;
|
||||||
|
|
||||||
identityExpression: shiftExpression ('is' | '!is') shiftExpression;
|
identityExpression: shiftExpression ('is' | '!' 'is') shiftExpression;
|
||||||
|
|
||||||
relExpression: shiftExpression relOperator shiftExpression;
|
relExpression: shiftExpression ('<' | '<=' | '>' | '>=' | '!<>=' | '!<>' | '<>' | '<>=' | '!>' | '!>=' | '!<' | '!<=') shiftExpression;
|
||||||
|
|
||||||
relOperator: '<'
|
inExpression: shiftExpression ('in' | '!' 'in') shiftExpression;
|
||||||
| '<='
|
|
||||||
| '>'
|
|
||||||
| '>='
|
|
||||||
| '!<>='
|
|
||||||
| '!<>'
|
|
||||||
| '<>'
|
|
||||||
| '<>='
|
|
||||||
| '!>'
|
|
||||||
| '!>='
|
|
||||||
| '!<'
|
|
||||||
| '!<='
|
|
||||||
;
|
|
||||||
|
|
||||||
inExpression: shiftExpression ('in' | '!in') shiftExpression;
|
|
||||||
|
|
||||||
shiftExpression: addExpression
|
shiftExpression: addExpression
|
||||||
| shiftExpression ('<<' | '>>' | '>>>') addExpression;
|
| shiftExpression ('<<' | '>>' | '>>>') addExpression;
|
||||||
|
@ -746,8 +827,63 @@ addExpression: mulExpression
|
||||||
| addExpression ('+' | '-' | '~') mulExpression
|
| addExpression ('+' | '-' | '~') mulExpression
|
||||||
;
|
;
|
||||||
|
|
||||||
mulExpression: unaryExpression
|
mulExpression: powExpression
|
||||||
| mulExpression ('*' | '/' | '%') unaryExpression
|
| mulExpression ('*' | '/' | '%') powExpression
|
||||||
|
;
|
||||||
|
|
||||||
|
powExpression: unaryExpression
|
||||||
|
| unaryExpression '^^' powExpression
|
||||||
|
;
|
||||||
|
|
||||||
|
unaryExpression: primaryExpression
|
||||||
|
| '&' unaryExpression
|
||||||
|
| '!' unaryExpression
|
||||||
|
| '*' unaryExpression
|
||||||
|
| '+' unaryExpression
|
||||||
|
| '-' unaryExpression
|
||||||
|
| '~' unaryExpression
|
||||||
|
| preIncDecExpression
|
||||||
|
| newExpression
|
||||||
|
| deleteExpression
|
||||||
|
| castExpression
|
||||||
|
| unaryExpression ('++'| '--') /* postIncDecExpression */ /* This causes an error in ANTLR */
|
||||||
|
| unaryExpression '[' ']'
|
||||||
|
| unaryExpression '[' argumentList ']'
|
||||||
|
| unaryExpression '[' assignExpression '..' assignExpression ']'
|
||||||
|
| unaryExpression '.' identifierOrTemplateInstance
|
||||||
|
;
|
||||||
|
|
||||||
|
postIncDecExpression: unaryExpression ('++' | '--')
|
||||||
|
;
|
||||||
|
|
||||||
|
preIncDecExpression: ('++' | '--') unaryExpression
|
||||||
|
;
|
||||||
|
|
||||||
|
primaryExpression: identifierOrTemplateInstance
|
||||||
|
| '.' identifierOrTemplateInstance
|
||||||
|
| type '.' Identifier
|
||||||
|
| typeofExpression
|
||||||
|
| typeidExpression
|
||||||
|
| 'this'
|
||||||
|
| 'super'
|
||||||
|
| 'null'
|
||||||
|
| 'true'
|
||||||
|
| 'false'
|
||||||
|
| '__FILE__'
|
||||||
|
| '__MODULE__'
|
||||||
|
| '__LINE__'
|
||||||
|
| '__FUNCTION__'
|
||||||
|
| '__PRETTY_FUNCTION__'
|
||||||
|
| IntegerLiteral
|
||||||
|
| FloatLiteral
|
||||||
|
| StringLiteral
|
||||||
|
| CharacterLiteral
|
||||||
|
| arrayLiteral
|
||||||
|
| assocArrayLiteral
|
||||||
|
| '(' expression ')'
|
||||||
|
| isExpression
|
||||||
|
| lambdaExpression
|
||||||
|
| traitsExpression
|
||||||
;
|
;
|
||||||
|
|
||||||
whileStatement: 'while' '(' expression ')' blockStatement
|
whileStatement: 'while' '(' expression ')' blockStatement
|
||||||
|
@ -759,6 +895,9 @@ doStatement: 'do' blockStatement 'while' '(' expression ')' ';'
|
||||||
blockStatement: '{' declarationsAndStatements? '}'
|
blockStatement: '{' declarationsAndStatements? '}'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
declarationsAndStatements: (declaration | statement)+
|
||||||
|
;
|
||||||
|
|
||||||
functionDeclaration: type Identifier parameters (functionBody | ';')
|
functionDeclaration: type Identifier parameters (functionBody | ';')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -815,7 +954,7 @@ builtinType: 'bool'
|
||||||
| 'void'
|
| 'void'
|
||||||
;
|
;
|
||||||
|
|
||||||
typeConstructors: typeConstructor typeConstructors?
|
typeConstructors: typeConstructor+
|
||||||
;
|
;
|
||||||
|
|
||||||
typeConstructor: 'const'
|
typeConstructor: 'const'
|
||||||
|
@ -830,15 +969,7 @@ typeof: 'typeof' '(' (expression | 'return') ')'
|
||||||
parameters: '(' (parameter (',' parameter)*)? ')'
|
parameters: '(' (parameter (',' parameter)*)? ')'
|
||||||
;
|
;
|
||||||
|
|
||||||
parameter: parameterAttribute? type ('...' | (Identifier ('=' defaultInitializerExpression)?))?
|
parameter: parameterAttribute* type ('...' | (Identifier ('=' defaultInitializerExpression)?))?
|
||||||
;
|
|
||||||
|
|
||||||
defaultInitializerExpression: assignExpression
|
|
||||||
| '__FILE__'
|
|
||||||
| '__MODULE__'
|
|
||||||
| '__LINE__'
|
|
||||||
| '__FUNCTION__'
|
|
||||||
| '__PRETTY_FUNCTION__'
|
|
||||||
;
|
;
|
||||||
|
|
||||||
parameterAttribute: 'auto'
|
parameterAttribute: 'auto'
|
||||||
|
@ -851,6 +982,14 @@ parameterAttribute: 'auto'
|
||||||
| typeConstructor
|
| typeConstructor
|
||||||
;
|
;
|
||||||
|
|
||||||
|
defaultInitializerExpression: assignExpression
|
||||||
|
| '__FILE__'
|
||||||
|
| '__MODULE__'
|
||||||
|
| '__LINE__'
|
||||||
|
| '__FUNCTION__'
|
||||||
|
| '__PRETTY_FUNCTION__'
|
||||||
|
;
|
||||||
|
|
||||||
functionAttribute: 'nothrow'
|
functionAttribute: 'nothrow'
|
||||||
| 'pure'
|
| 'pure'
|
||||||
| atAttribute
|
| atAttribute
|
||||||
|
@ -879,10 +1018,10 @@ outStatement: 'out' ('(' Identifier ')')? blockStatement
|
||||||
bodyStatement: 'body' blockStatement
|
bodyStatement: 'body' blockStatement
|
||||||
;
|
;
|
||||||
|
|
||||||
aliasDeclaration: 'alias' (aliasinitializer (',' aliasinitializer)* | type declarator) ';'
|
aliasDeclaration: 'alias' (aliasInitializer (',' aliasInitializer)* | type declarator) ';'
|
||||||
;
|
;
|
||||||
|
|
||||||
aliasinitializer: Identifier '=' type
|
aliasInitializer: Identifier '=' type
|
||||||
;
|
;
|
||||||
|
|
||||||
variableDeclaration: type declarator (',' declarator)* ';'
|
variableDeclaration: type declarator (',' declarator)* ';'
|
||||||
|
@ -939,7 +1078,7 @@ protectionAttribute: 'private'
|
||||||
| 'export'
|
| 'export'
|
||||||
;
|
;
|
||||||
|
|
||||||
traitsExpression: 'traits' '(' Identifier ',' traitsArgument (',' traitsArgument)* ')'
|
traitsExpression: '__traits' '(' Identifier ',' traitsArgument (',' traitsArgument)* ')'
|
||||||
;
|
;
|
||||||
|
|
||||||
traitsArgument: assignExpression
|
traitsArgument: assignExpression
|
||||||
|
|
Loading…
Reference in New Issue