diff --git a/stdx/d/parser.d b/stdx/d/parser.d index 3b1830e..05e8354 100644 --- a/stdx/d/parser.d +++ b/stdx/d/parser.d @@ -1,5 +1,13 @@ // Written in the D programming language +/** + * MACROS: + * GRAMMAR =
$0
+ * RULEDEF = $(B $(DDOC_ANCHOR $0) $0) + * RULE = $(LINK2 #$0, $0) + * LITERAL = $(D_STRING $(I $0)) + */ + module stdx.d.parser; import stdx.d.lexer; @@ -17,6 +25,7 @@ import std.string : format; /** * Params: * tokens = the tokens parsed by std.d.lexer + * fileName = the name of the file being parsed * messageFunction = a function to call on error or warning messages. * The parameters are the file name, line number, column number, * the error or warning message, and a boolean (true means error, false diff --git a/stdx/d/parser.html b/stdx/d/parser.html new file mode 100644 index 0000000..8ba7bbb --- /dev/null +++ b/stdx/d/parser.html @@ -0,0 +1,2201 @@ + + + stdx.d.parser + +

stdx.d.parser

+ + +
Module parseModule(const(Token)[] tokens, string fileName, void function(string, size_t, size_t, string, bool) messageFunction = null); +
+
Params:
+ + + + + + +
const(Token)[] tokensthe tokens parsed by std.d.lexer
string fileNamethe name of the file being parsed
void function(string, size_t, size_t, string, bool) messageFunctiona function to call on error or warning messages. + The parameters are the file name, line number, column number, + the error or warning message, and a boolean (true means error, false + means warning).

+Returns:
+the parsed module

+ +
+
class Parser; +
+
Parser structure

+ +
ExpressionNode parseAddExpression(); +
+
Parses an AddExpression. +

+
 addExpression:
+       mulExpression
+     | addExpression ('+' | '-' | '~') mulExpression
+     ;


+ +
+
AliasDeclaration parseAliasDeclaration(); +
+
Parses an AliasDeclaration. +

+
 aliasDeclaration:
+       'alias' aliasInitializer (',' aliasInitializer)* ';'
+     | 'alias' type identifier ';'
+     ;


+ +
+
AliasInitializer parseAliasInitializer(); +
+
Parses an AliasInitializer +
 aliasInitializer:
+     Identifier '=' type
+     ;


+ +
+
AliasThisDeclaration parseAliasThisDeclaration(); +
+
Parses an AliasThisDeclaration +
 aliasThisDeclaration:
+     'alias' Identifier 'this' ';'
+     ;


+ +
+
AlignAttribute parseAlignAttribute(); +
+
Parses an AlignAttribute. +
 alignAttribute:
+     'align' ('(' IntegerLiteral ')')?
+     ;


+ +
+
ExpressionNode parseAndAndExpression(); +
+
Parses an AndAndExpression +
 andAndExpression:
+       orExpression
+     | andAndExpression '&&' orExpression
+     ;


+ +
+
ExpressionNode parseAndExpression(); +
+
Parses an AndExpression +

+
 andExpression:
+       cmpExpression
+     | andExpression '&' cmpExpression
+     ;


+ +
+
ArgumentList parseArgumentList(); +
+
Parses an ArgumentList +

+
 argumentList:
+     assignExpression (',' assignExpression?)*
+     ;


+ +
+
Arguments parseArguments(); +
+
Parses Arguments +

+
 arguments:
+     '(' argumentList? ')'
+     ;


+ +
+
ArrayInitializer parseArrayInitializer(); +
+
Parses an ArrayInitializer +

+
 arrayInitializer:
+       '[' ']'
+     | '[' arrayMemberInitialization (',' arrayMemberInitialization?)* ']'
+     ;


+ +
+
ArrayLiteral parseArrayLiteral(); +
+
Parses an ArrayLiteral +

+
 arrayLiteral:
+     '[' (assignExpression (',' assignExpression)*)? ']'
+     ;


+ +
+
ArrayMemberInitialization parseArrayMemberInitialization(); +
+
Parses an ArrayMemberInitialization +

+
 arrayMemberInitialization:
+     (assignExpression ':')? nonVoidInitializer
+     ;


+ +
+
ExpressionNode parseAsmAddExp(); +
+
Parses an AsmAddExp +

+
 asmAddExp:
+       asmMulExp
+     | asmAddExp ('+' | '-') asmMulExp
+     ;


+ +
+
AsmAndExp parseAsmAndExp(); +
+
Parses an AsmAndExp +

+
 asmAndExp:
+     asmEqualExp ('&' asmEqualExp)?
+     ;


+ +
+
AsmBrExp parseAsmBrExp(); +
+
Parses an AsmBrExp +

+
 asmBrExp:
+       asmUnaExp
+     | asmBrExp '[' asmExp ']'
+     ;


+ +
+
AsmEqualExp parseAsmEqualExp(); +
+
Parses an AsmEqualExp +

+
 asmEqualExp:
+     asmRelExp (('==' | '!=') asmRelExp)?
+     ;


+ +
+
AsmExp parseAsmExp(); +
+
Parses an AsmExp +

+
 asmExp:
+     asmLogOrExp ('?' asmExp ':' asmExp)?
+     ;


+ +
+
AsmInstruction parseAsmInstruction(); +
+
Parses an AsmInstruction +

+
 asmInstruction:
+     Identifier
+     | 'align' IntegerLiteral
+     | 'align' Identifier
+     | Identifier ':' asmInstruction
+     | Identifier asmExp
+     | Identifier operands
+     ;


+ +
+
AsmLogAndExp parseAsmLogAndExp(); +
+
Parses an AsmLogAndExp +

+
 asmLogAndExp:
+     asmOrExp ('&&' asmOrExp)?
+     ;


+ +
+
AsmLogOrExp parseAsmLogOrExp(); +
+
Parses an AsmLogOrExp +

+
 asmLogOrExp:
+     asmLogAndExp ('||' asmLogAndExp)?
+     ;


+ +
+
AsmMulExp parseAsmMulExp(); +
+
Parses an AsmMulExp +

+
 asmMulExp:
+     asmBrExp (('*' | '/' | '%') asmBrExp)?
+     ;


+ +
+
AsmOrExp parseAsmOrExp(); +
+
Parses an AsmOrExp +

+
 asmOrExp:
+     asmXorExp ('|' asmXorExp)?
+     ;


+ +
+
AsmPrimaryExp parseAsmPrimaryExp(); +
+
Parses an AsmPrimaryExp +

+
 asmPrimaryExp:
+       IntegerLiteral
+     | FloatLiteral
+     | register
+     | identifierChain
+     | '$'
+     ;


+ +
+
AsmRelExp parseAsmRelExp(); +
+
Parses an AsmRelExp +

+
 asmRelExp:
+     asmShiftExp (('<' | '<=' | '>' | '>=') asmShiftExp)?
+     ;


+ +
+
AsmShiftExp parseAsmShiftExp(); +
+
Parses an AsmShiftExp +

+
 asmShiftExp:
+     asmAddExp (('<<' | '>>' | '>>>') asmAddExp)?
+     ;


+ +
+
AsmStatement parseAsmStatement(); +
+
Parses an AsmStatement +

+
 asmStatement:
+     'asm' '{' asmInstruction+ '}'
+     ;


+ +
+
AsmTypePrefix parseAsmTypePrefix(); +
+
Parses an AsmTypePrefix +

+
 asmTypePrefix:
+       Identifier Identifier
+     | 'byte' Identifier
+     | 'short' Identifier
+     | 'int' Identifier
+     | 'float' Identifier
+     | 'double' Identifier
+     | 'real' Identifier
+     ;


+ +
+
AsmUnaExp parseAsmUnaExp(); +
+
Parses an AsmUnaExp +

+
 asmUnaExp:
+       asmTypePrefix asmExp
+     | Identifier asmExp
+     | '+' asmUnaExp
+     | '-' asmUnaExp
+     | '!' asmUnaExp
+     | '~' asmUnaExp
+     | asmPrimaryExp
+     ;


+ +
+
AsmXorExp parseAsmXorExp(); +
+
Parses an AsmXorExp +

+
 asmXorExp:
+     asmAndExp ('^' asmAndExp)?
+     ;


+ +
+
AssertExpression parseAssertExpression(); +
+
Parses an AssertExpression +

+
 assertExpression:
+     'assert' '(' assignExpression (',' assignExpression)? ')'
+     ;


+ +
+
AssignExpression parseAssignExpression(); +
+
Parses an AssignExpression +

+
 assignExpression:
+     ternaryExpression (assignOperator assignExpression)?
+     ;
+ assignOperator:
+       '='
+     | '>>>='
+     | '>>='
+     | '<<='
+     | '+='
+     | '-='
+     | '*='
+     | '%='
+     | '&='
+     | '/='
+     | '|='
+     | '^^='
+     | '^='
+     | '~='
+     ;


+ +
+
AssocArrayLiteral parseAssocArrayLiteral(); +
+
Parses an AssocArrayLiteral +

+
 assocArrayLiteral:
+     '[' keyValuePairs ']'
+     ;


+ +
+
AtAttribute parseAtAttribute(); +
+
Parses an AtAttribute +

+
 atAttribute:
+     '@' (Identifier | '(' argumentList ')' | functionCallExpression)
+     ;


+ +
+
Attribute parseAttribute(); +
+
Parses an Attribute +

+
 attribute:
+       alignAttribute
+     | linkageAttribute
+     | pragmaExpression
+     | storageClass
+     | 'export'
+     | 'package'
+     | 'private'
+     | 'protected'
+     | 'public'
+     ;


+ +
+
AttributeDeclaration parseAttributeDeclaration(Attribute attribute = null); +
+
Parses an AttributeDeclaration +

+
 attributeDeclaration:
+     attribute ':'
+     ;


+ +
+
AutoDeclaration parseAutoDeclaration(); +
+
Parses an AutoDeclaration +

+
 autoDeclaration:
+     storageClass Identifier '=' initializer (',' Identifier '=' initializer)* ';'
+     ;


+ +
+
BlockStatement parseBlockStatement(); +
+
Parses a BlockStatement +

+
 blockStatement:
+     '{' declarationsAndStatements? '}'
+     ;


+ +
+
BodyStatement parseBodyStatement(); +
+
Parses a BodyStatement +

+
 bodyStatement:
+     'body' blockStatement
+     ;


+ +
+
BreakStatement parseBreakStatement(); +
+
Parses a BreakStatement +

+
 breakStatement:
+     'break' Identifier? ';'
+     ;


+ +
+
BaseClass parseBaseClass(); +
+
Parses a BaseClass +

+
 baseClass:
+     (typeofExpression '.')? identifierOrTemplateChain
+     ;


+ +
+
BaseClassList parseBaseClassList(); +
+
Parses a BaseClassList +

+
 baseClassList:
+     baseClass (',' baseClass)*
+     ;


+ +
+
IdType parseBasicType(); +
+
Parses an BuiltinType +

+
 builtinType:
+      'bool'
+    | 'byte'
+    | 'ubyte'
+    | 'short'
+    | 'ushort'
+    | 'int'
+    | 'uint'
+    | 'long'
+    | 'ulong'
+    | 'char'
+    | 'wchar'
+    | 'dchar'
+    | 'float'
+    | 'double'
+    | 'real'
+    | 'ifloat'
+    | 'idouble'
+    | 'ireal'
+    | 'cfloat'
+    | 'cdouble'
+    | 'creal'
+    | 'void'
+    ;


+ +
+
CaseRangeStatement parseCaseRangeStatement(AssignExpression low = null); +
+
Parses a CaseRangeStatement +

+
 caseRangeStatement:
+     'case' assignExpression ':' '...' 'case' assignExpression ':' declarationsAndStatements
+     ;


+ +
+
CaseStatement parseCaseStatement(ArgumentList argumentList = null); +
+
Parses an CaseStatement +

+
 caseStatement:
+     'case' argumentList ':' declarationsAndStatements
+     ;


+ +
+
CastExpression parseCastExpression(); +
+
Parses a CastExpression +

+
 castExpression:
+     'cast' '(' (type | castQualifier)? ')' unaryExpression
+     ;


+ +
+
CastQualifier parseCastQualifier(); +
+
Parses a CastQualifier +

+
 castQualifier:
+      'const'
+    | 'const' 'shared'
+    | 'immutable'
+    | 'inout'
+    | 'inout' 'shared'
+    | 'shared'
+    | 'shared' 'const'
+    | 'shared' 'inout'
+    ;


+ +
+
Catch parseCatch(); +
+
Parses a Catch +

+
 catch:
+     'catch' '(' type Identifier? ')' declarationOrStatement
+     ;


+ +
+
Catches parseCatches(); +
+
Parses a Catches +

+
 catches:
+       catch+
+     | catch* lastCatch
+     ;


+ +
+
ClassDeclaration parseClassDeclaration(); +
+
Parses a ClassDeclaration +

+
 classDeclaration:
+     'class' Identifier (templateParameters constraint?)? (':' baseClassList)? structBody
+     ;


+ +
+
ExpressionNode parseCmpExpression(); +
+
Parses a CmpExpression +

+
 cmpExpression:
+       shiftExpression
+     | equalExpression
+     | identityExpression
+     | relExpression
+     | inExpression
+     ;


+ +
+
CompileCondition parseCompileCondition(); +
+
Parses a CompileCondition +

+
 compileCondition:
+       versionCondition
+     | debugCondition
+     | staticIfCondition
+     ;


+ +
+
ConditionalDeclaration parseConditionalDeclaration(); +
+
Parses a ConditionalDeclaration +

+
 conditionalDeclaration:
+       compileCondition declaration
+     | compileCondition ':' declaration+
+     | compileCondition declaration ('else' declaration)?
+     ;


+ +
+
ConditionalStatement parseConditionalStatement(); +
+
Parses a ConditionalStatement +

+
 conditionalStatement:
+     compileCondition declarationOrStatement ('else' declarationOrStatement)?
+     ;


+ +
+
Constraint parseConstraint(); +
+
Parses a Constraint +

+
 constraint:
+     'if' '(' expression ')'
+     ;


+ +
+
Constructor parseConstructor(); +
+
Parses a Constructor +

+
 constructor:
+       'this' templateParameters parameters memberFunctionAttribute* constraint? (functionBody | ';')
+     ;


+ +
+
ContinueStatement parseContinueStatement(); +
+
Parses an ContinueStatement +

+
 continueStatement:
+     'continue' Identifier? ';'
+     ;


+ +
+
DebugCondition parseDebugCondition(); +
+
Parses a DebugCondition +

+
 debugCondition:
+     'debug' ('(' (IntegerLiteral | Identifier) ')')?
+     ;


+ +
+
DebugSpecification parseDebugSpecification(); +
+
Parses a DebugSpecification +

+
 debugSpecification:
+     'debug' '=' (Identifier | IntegerLiteral) ';'
+     ;


+ +
+
Declaration parseDeclaration(); +
+
Parses a Declaration +

+
 declaration:
+     attribute* 
+     ;
+  declaration2:
+       aliasDeclaration
+     | aliasThisDeclaration
+     | classDeclaration
+     | conditionalDeclaration
+     | constructor
+     | destructor
+     | enumDeclaration
+     | functionDeclaration
+     | importDeclaration
+     | interfaceDeclaration
+     | mixinDeclaration
+     | mixinTemplateDeclaration
+     | pragmaDeclaration
+     | sharedStaticConstructor
+     | sharedStaticDestructor
+     | staticAssertDeclaration
+     | staticConstructor
+     | staticDestructor
+     | structDeclaration
+     | templateDeclaration
+     | unionDeclaration
+     | unittest
+     | variableDeclaration
+     | attributeDeclaration
+     | invariant
+     | '{' declaration+ '}'
+     ;


+ +
+
DeclarationsAndStatements parseDeclarationsAndStatements(); +
+
Parses DeclarationsAndStatements +

+
 declarationsAndStatements:
+     declarationOrStatement+
+     ;


+ +
+
DeclarationOrStatement parseDeclarationOrStatement(); +
+
Parses a DeclarationOrStatement +

+
 declarationOrStatement:
+       declaration
+     | statement
+     ;


+ +
+
Declarator parseDeclarator(); +
+
Parses a Declarator +

+
 declarator:
+     Identifier ('=' initializer)?
+     ;


+ +
+
DefaultStatement parseDefaultStatement(); +
+
Parses a DefaultStatement +

+
 defaultStatement:
+     'default' ':' declarationsAndStatements
+     ;


+ +
+
DeleteExpression parseDeleteExpression(); +
+
Parses a DeleteExpression +

+
 deleteExpression:
+     'delete' unaryExpression
+     ;


+ +
+
Deprecated parseDeprecated(); +
+
Parses a Deprecated attribute +

+
 deprecated:
+     'deprecated' ('(' assignExpression ')')?
+     ;


+ +
+
Destructor parseDestructor(); +
+
Parses a Destructor +

+
 destructor:
+     '~' 'this' '(' ')' (functionBody | ';')
+     ;


+ +
+
DoStatement parseDoStatement(); +
+
Parses a DoStatement +

+
 doStatement:
+     'do' statementNoCaseNoDefault 'while' '(' expression ')' ';'
+     ;


+ +
+
EnumBody parseEnumBody(); +
+
Parses an EnumBody +

+
 enumBody:
+       ';'
+     | '{' enumMember (',' enumMember?)* '}'
+     ;


+ +
+
EnumDeclaration parseEnumDeclaration(); +
+
Parses an EnumDeclaration +

+
 enumDeclaration:
+     'enum' Identifier? (':' type)? enumBody
+     ;


+ +
+
EnumMember parseEnumMember(); +
+
Parses an EnumMember +

+
 enumMember:
+       Identifier
+     | (Identifier | type) '=' assignExpression
+     ;


+ +
+
EqualExpression parseEqualExpression(ExpressionNode shift = null); +
+
Parses an EqualExpression +

+
 equalExpression:
+     shiftExpression ('==' | '!=') shiftExpression
+     ;


+ +
+
Expression parseExpression(); +
+
Parses an Expression +

+
 expression:
+     assignExpression (',' assignExpression)*
+     ;


+ +
+
ExpressionStatement parseExpressionStatement(Expression expression = null); +
+
Parses an ExpressionStatement +

+
 expressionStatement:
+     expression ';'
+     ;


+ +
+
FinalSwitchStatement parseFinalSwitchStatement(); +
+
Parses a FinalSwitchStatement +

+
 finalSwitchStatement:
+     'final' switchStatement
+     ;


+ +
+
Finally parseFinally(); +
+
Parses a Finally +

+
 finally:
+     'finally' declarationOrStatement
+     ;


+ +
+
ForStatement parseForStatement(); +
+
Parses a ForStatement +

+
 forStatement:
+     'for' '(' declarationOrStatement expression? ';' expression? ')' declarationOrStatement
+     ;


+ +
+
ForeachStatement parseForeachStatement(); +
+
Parses a ForeachStatement +

+
 foreachStatement:
+       ('foreach' | 'foreach_reverse') '(' foreachTypeList ';' expression ')' declarationOrStatement
+     | ('foreach' | 'foreach_reverse') '(' foreachType ';' expression '..' expression ')' declarationOrStatement
+     ;


+ +
+
ForeachType parseForeachType(); +
+
Parses a ForeachType +

+
 foreachType:
+     typeConstructors? type? Identifier
+     ;


+ +
+
ForeachTypeList parseForeachTypeList(); +
+
Parses a ForeachTypeList +

+
 foreachTypeList:
+     foreachType (',' foreachType)*
+     ;


+ +
+
FunctionAttribute parseFunctionAttribute(bool validate = true); +
+
Parses a FunctionAttribute +

+
 functionAttribute:
+       atAttribute
+     | 'pure'
+     | 'nothrow'
+     ;


+ +
+
FunctionBody parseFunctionBody(); +
+
Parses a FunctionBody +

+
 functionBody:
+       blockStatement
+     | (inStatement | outStatement | outStatement inStatement | inStatement outStatement)? bodyStatement
+     ;


+ +
+
FunctionCallExpression parseFunctionCallExpression(UnaryExpression unary = null); +
+
Parses a FunctionCallExpression +

+
 functionCallExpression:
+     unaryExpression templateArguments? arguments
+     ;


+ +
+
FunctionCallStatement parseFunctionCallStatement(); +
+
Parses a FunctionCallStatement +

+
 functionCallStatement:
+     functionCallExpression ';'
+     ;


+ +
+
FunctionDeclaration parseFunctionDeclaration(Type type = null, bool isAuto = false); +
+
Parses a FunctionDeclaration +

+
 functionDeclaration:
+       (storageClass | type) Identifier templateParameters parameters memberFunctionAttribute* constraint? (functionBody | ';')
+     ;


+ +
+
FunctionLiteralExpression parseFunctionLiteralExpression(); +
+
Parses a FunctionLiteralExpression +

+
 functionLiteralExpression:
+     (('function' | 'delegate') type?)? (parameters functionAttribute*)? functionBody
+     ;


+ +
+
GotoStatement parseGotoStatement(); +
+
Parses a GotoStatement +

+
 gotoStatement:
+     'goto' (Identifier | 'default' | 'case' expression?) ';'
+     ;


+ +
+
IdentifierChain parseIdentifierChain(); +
+
Parses an IdentifierChain +

+
 identifierChain:
+     Identifier ('.' Identifier)*
+     ;


+ +
+
IdentifierList parseIdentifierList(); +
+
Parses an IdentifierList +

+
 identifierList:
+     Identifier (',' Identifier)*
+     ;


+ +
+
IdentifierOrTemplateChain parseIdentifierOrTemplateChain(); +
+
Parses an IdentifierOrTemplateChain +

+
 identifierOrTemplateChain:
+     identifierOrTemplateInstance ('.' identifierOrTemplateInstance)*
+     ;


+ +
+
IdentifierOrTemplateInstance parseIdentifierOrTemplateInstance(); +
+
Parses an IdentifierOrTemplateInstance +

+
 identifierOrTemplateInstance:
+       Identifier
+     | templateInstance
+     ;


+ +
+
ExpressionNode parseIdentityExpression(ExpressionNode shift = null); +
+
Parses an IdentityExpression +

+
 identityExpression:
+     shiftExpression ('is' | '!' 'is') shiftExpression
+     ;


+ +
+
IfStatement parseIfStatement(); +
+
Parses an IfStatement +

+
 ifStatement:
+     'if' '(' ifCondition ')' declarationOrStatement ('else' declarationOrStatement)?
+  ifCondition:
+       'auto' Identifier '=' expression
+     | type Identifier '=' expression
+     | expression
+     ;


+ +
+
ImportBind parseImportBind(); +
+
Parses an ImportBind +

+
 importBind:
+     Identifier ('=' Identifier)?
+     ;


+ +
+
ImportBindings parseImportBindings(SingleImport singleImport); +
+
Parses ImportBindings +

+
 importBindings:
+     singleImport ':' importBind (',' importBind)*
+     ;


+ +
+
ImportDeclaration parseImportDeclaration(); +
+
Parses an ImportDeclaration +

+
 importDeclaration:
+       'import' singleImport (',' singleImport)* (',' importBindings)? ';'
+     | 'import' importBindings ';'
+     ;


+ +
+
ImportExpression parseImportExpression(); +
+
Parses an ImportExpression +

+
 importExpression:
+     'import' '(' assignExpression ')'
+     ;


+ +
+
IndexExpression parseIndexExpression(UnaryExpression unaryExpression = null); +
+
Parses an IndexExpression +

+
 indexExpression:
+     unaryExpression '[' argumentList ']'
+     ;


+ +
+
ExpressionNode parseInExpression(ExpressionNode shift = null); +
+
Parses an InExpression +

+
 inExpression:
+     shiftExpression ('in' | '!' 'in') shiftExpression
+     ;


+ +
+
InStatement parseInStatement(); +
+
Parses an InStatement +

+
 inStatement:
+     'in' blockStatement
+     ;


+ +
+
Initialize parseInitialize(); +
+
Parses an Initialize +

+
 initialize:
+       ';'
+     | statementNoCaseNoDefault
+     ;


+ +
+
Initializer parseInitializer(); +
+
Parses an Initializer +

+
 initializer:
+       'void'
+     | nonVoidInitializer
+     ;


+ +
+
InterfaceDeclaration parseInterfaceDeclaration(); +
+
Parses an InterfaceDeclaration +

+
 interfaceDeclaration:
+     'interface' Identifier (templateParameters constraint?)? (':' baseClassList)? structBody
+     ;


+ +
+
Invariant parseInvariant(); +
+
Parses an Invariant +

+
 invariant:
+     'invariant' ('(' ')')? blockStatement
+     ;


+ +
+
IsExpression parseIsExpression(); +
+
Parses an IsExpression +

+
 isExpression:
+     'is' '(' type Identifier? ((':' | '==') typeSpecialization (',' templateParameterList)?)? ')'
+     ;


+ +
+
KeyValuePair parseKeyValuePair(); +
+
Parses a KeyValuePair +

+
 keyValuePair:
+     assignExpression ':' assignExpression
+     ;


+ +
+
KeyValuePairs parseKeyValuePairs(); +
+
Parses KeyValuePairs +

+
 keyValuePairs:
+     keyValuePair (',' keyValuePair)* ','?
+     ;


+ +
+
LabeledStatement parseLabeledStatement(); +
+
Parses a LabeledStatement +

+
 labeledStatement:
+     Identifier ':' declarationOrStatement
+     ;


+ +
+
LambdaExpression parseLambdaExpression(); +
+
Parses a LambdaExpression +

+
 lambdaExpression:
+       Identifier '=>' assignExpression
+     | 'function' parameters functionAttribute* '=>' assignExpression
+     | 'delegate' parameters functionAttribute* '=>' assignExpression
+     | parameters functionAttribute* '=>' assignExpression
+     ;


+ +
+
LastCatch parseLastCatch(); +
+
Parses a LastCatch +

+
 lastCatch:
+     'catch' statementNoCaseNoDefault
+     ;


+ +
+
LinkageAttribute parseLinkageAttribute(); +
+
Parses a LinkageAttribute +

+
 linkageAttribute:
+     'extern' '(' Identifier '++'? ')'
+     ;


+ +
+
MemberFunctionAttribute parseMemberFunctionAttribute(); +
+
Parses a MemberFunctionAttribute +

+
 memberFunctionAttribute:
+       functionAttribute
+     | 'immutable'
+     | 'inout'
+     | 'shared'
+     | 'const'
+     ;


+ +
+
MixinDeclaration parseMixinDeclaration(); +
+
Parses a MixinDeclaration +

+
 mixinDeclaration:
+       mixinExpression ';'
+     | templateMixinExpression ';'
+     ;


+ +
+
MixinExpression parseMixinExpression(); +
+
Parses a MixinExpression +

+
 mixinExpression:
+     'mixin' '(' assignExpression ')'
+     ;


+ +
+
MixinTemplateDeclaration parseMixinTemplateDeclaration(); +
+
Parses a MixinTemplateDeclaration +

+
 mixinTemplateDeclaration:
+     'mixin' templateDeclaration
+     ;


+ +
+
MixinTemplateName parseMixinTemplateName(); +
+
Parses a MixinTemplateName +

+
 mixinTemplateName:
+       symbol
+     | typeofExpression '.' identifierOrTemplateChain
+     ;


+ +
+
Module parseModule(); +
+
Parses a Module +

+
 module:
+     moduleDeclaration? declaration*
+     ;


+ +
+
ModuleDeclaration parseModuleDeclaration(); +
+
Parses a ModuleDeclaration +

+
 moduleDeclaration:
+     'module' identifierChain ';'
+     ;


+ +
+
ExpressionNode parseMulExpression(); +
+
Parses a MulExpression +
 mulExpression:
+       powExpression
+     | mulExpression ('*' | '/' | '%') powExpression
+     ;


+ +
+
NewAnonClassExpression parseNewAnonClassExpression(); +
+
Parses a NewAnonClassExpression +

+
 newAnonClassExpression:
+     'new' arguments? 'class' arguments? baseClassList? structBody
+     ;


+ +
+
NewExpression parseNewExpression(); +
+
Parses a NewExpression +

+
 newExpression:
+       'new' type ('[' assignExpression ']' | arguments)?
+     | newAnonClassExpression
+     ;


+ +
+
StatementNoCaseNoDefault parseStatementNoCaseNoDefault(); +
+
Parses a StatementNoCaseNoDefault +

+
 statementNoCaseNoDefault:
+       labeledStatement
+     | blockStatement
+     | ifStatement
+     | whileStatement
+     | doStatement
+     | forStatement
+     | foreachStatement
+     | switchStatement
+     | finalSwitchStatement
+     | continueStatement
+     | breakStatement
+     | returnStatement
+     | gotoStatement
+     | withStatement
+     | synchronizedStatement
+     | tryStatement
+     | throwStatement
+     | scopeGuardStatement
+     | asmStatement
+     | conditionalStatement
+     | staticAssertStatement
+     | versionSpecification
+     | debugSpecification
+     | expressionStatement
+     ;


+ +
+
NonVoidInitializer parseNonVoidInitializer(); +
+
Parses a NonVoidInitializer +

+
 nonVoidInitializer:
+       assignExpression
+     | arrayInitializer
+     | structInitializer
+     ;


+ +
+
Operands parseOperands(); +
+
Parses Operands +

+
 operands:
+     asmExp+
+     ;


+ +
+
ExpressionNode parseOrExpression(); +
+
Parses an OrExpression +

+
 orExpression:
+       xorExpression
+     | orExpression '|' xorExpression
+     ;


+ +
+
ExpressionNode parseOrOrExpression(); +
+
Parses an OrOrExpression +

+
 orOrExpression:
+       andAndExpression
+     | orOrExpression '||' andAndExpression
+     ;


+ +
+
OutStatement parseOutStatement(); +
+
Parses an OutStatement +

+
 outStatement:
+     'out' ('(' Identifier ')')? blockStatement
+     ;


+ +
+
Parameter parseParameter(); +
+
Parses a Parameter +

+
 parameter:
+     parameterAttribute* type (Identifier? '...' | (Identifier? ('=' assignExpression)?))?
+     ;


+ +
+
IdType parseParameterAttribute(bool validate = false); +
+
Parses a ParameterAttribute +

+
 parameterAttribute:
+       typeConstructor
+     | 'final'
+     | 'in'
+     | 'lazy'
+     | 'out'
+     | 'ref'
+     | 'scope'
+     | 'auto'
+     ;


+ +
+
Parameters parseParameters(); +
+
Parses Parameters +

+
 parameters:
+       '(' parameter (',' parameter)* (',' '...')? ')'
+     | '(' '...' ')'
+     | '(' ')'
+     ;


+ +
+
Postblit parsePostblit(); +
+
Parses a Postblit +

+
 postblit:
+     'this' '(' 'this' ')' (functionBody | ';')
+     ;


+ +
+
PostIncDecExpression parsePostIncDecExpression(UnaryExpression unary = null); +
+
Parses a PostIncDecExpression +

+
 postIncDecExpression:
+     unaryExpression ('++' | '--')
+     ;


+ +
+
ExpressionNode parsePowExpression(); +
+
Parses a PowExpression +

+
 powExpression:
+       unaryExpression
+     | powExpression '^^' unaryExpression
+     ;


+ +
+
PragmaDeclaration parsePragmaDeclaration(); +
+
Parses a PragmaDeclaration +

+
 pragmaDeclaration:
+     pragmaExpression ';'
+     ;


+ +
+
PragmaExpression parsePragmaExpression(); +
+
Parses a PragmaExpression +

+
 pragmaExpression:
+     'pragma' '(' Identifier (',' argumentList)? ')'
+     ;


+ +
+
PreIncDecExpression parsePreIncDecExpression(); +
+
Parses a PreIncDecExpression +

+
 preIncDecExpression:
+     ('++' | '--') unaryExpression
+     ;


+ +
+
PrimaryExpression parsePrimaryExpression(); +
+
Parses a PrimaryExpression +

+
 primaryExpression:
+       identifierOrTemplateInstance
+     | '.' identifierOrTemplateInstance
+     | basicType '.' Identifier
+     | typeofExpression
+     | typeidExpression
+     | vector
+     | arrayLiteral
+     | assocArrayLiteral
+     | '(' expression ')'
+     | isExpression
+     | lambdaExpression
+     | functionLiteralExpression
+     | traitsExpression
+     | mixinExpression
+     | importExpression
+     | '$'
+     | 'this'
+     | 'super'
+     | 'null'
+     | 'true'
+     | 'false'
+     | '__DATE__'
+     | '__TIME__'
+     | '__TIMESTAMP__'
+     | '__VENDOR__'
+     | '__VERSION__'
+     | '__FILE__'
+     | '__LINE__'
+     | '__MODULE__'
+     | '__FUNCTION__'
+     | '__PRETTY_FUNCTION__'
+     | IntegerLiteral
+     | FloatLiteral
+     | StringLiteral+
+     | CharacterLiteral
+     ;


+ +
+
Register parseRegister(); +
+
Parses a Register +

+
 register:
+     Identifier
+     | Identifier '(' IntegerLiteral ')'
+     ;


+ +
+
ExpressionNode parseRelExpression(ExpressionNode shift); +
+
Parses a RelExpression +

+
 relExpression:
+       shiftExpression
+     | relExpression relOperator shiftExpression
+     ;
+ relOperator:
+       '<'
+     | '<='
+     | '>'
+     | '>='
+     | '!<>='
+     | '!<>'
+     | '<>'
+     | '<>='
+     | '!>'
+     | '!>='
+     | '!<'
+     | '!<='
+     ;


+ +
+
ReturnStatement parseReturnStatement(); +
+
Parses a ReturnStatement +

+
 returnStatement:
+     'return' expression? ';'
+     ;


+ +
+
ScopeGuardStatement parseScopeGuardStatement(); +
+
Parses a ScopeGuardStatement +

+
 scopeGuardStatement:
+     'scope' '(' Identifier ')' statementNoCaseNoDefault
+     ;


+ +
+
SharedStaticConstructor parseSharedStaticConstructor(); +
+
Parses a SharedStaticConstructor +

+
 sharedStaticConstructor:
+     'shared' 'static' 'this' '(' ')' functionBody
+     ;


+ +
+
SharedStaticDestructor parseSharedStaticDestructor(); +
+
Parses a SharedStaticDestructor +

+
 sharedStaticDestructor:
+     'shared' 'static' '~' 'this' '(' ')' functionBody
+     ;


+ +
+
ExpressionNode parseShiftExpression(); +
+
Parses a ShiftExpression +

+
 shiftExpression:
+       addExpression
+     | shiftExpression ('<<' | '>>' | '>>>') addExpression
+     ;


+ +
+
SingleImport parseSingleImport(); +
+
Parses a SingleImport +

+
 singleImport:
+     (Identifier '=')? identifierChain
+     ;


+ +
+
SliceExpression parseSliceExpression(UnaryExpression unary = null); +
+
Parses a SliceExpression +

+
 sliceExpression:
+       unaryExpression '[' assignExpression '..' assignExpression ']'
+     | unaryExpression '[' ']'
+     ;


+ +
+
Statement parseStatement(); +
+
Parses a Statement +

+
 statement:
+       statementNoCaseNoDefault
+     | caseStatement
+     | caseRangeStatement
+     | defaultStatement
+     ;


+ +
+
StaticAssertDeclaration parseStaticAssertDeclaration(); +
+
Parses a StaticAssertDeclaration +

+
 staticAssertDeclaration:
+     staticAssertStatement
+     ;


+ +
+
StaticAssertStatement parseStaticAssertStatement(); +
+
Parses a StaticAssertStatement +

+
 staticAssertStatement:
+     'static' assertExpression ';'
+     ;


+ +
+
StaticConstructor parseStaticConstructor(); +
+
Parses a StaticConstructor +

+
 staticConstructor:
+     'static' 'this' '(' ')' functionBody
+     ;


+ +
+
StaticDestructor parseStaticDestructor(); +
+
Parses a StaticDestructor +

+
 staticDestructor:
+     'static' '~' 'this' '(' ')' functionBody
+     ;


+ +
+
StaticIfCondition parseStaticIfCondition(); +
+
Parses an StaticIfCondition +

+
 staticIfCondition:
+     'static' 'if' '(' assignExpression ')'
+     ;


+ +
+
StorageClass parseStorageClass(); +
+
Parses an StorageClass +

+
 storageClass:
+       atAttribute
+     | typeConstructor
+     | deprecated
+     | 'abstract'
+     | 'auto'
+     | 'enum'
+     | 'extern'
+     | 'final'
+     | 'nothrow'
+     | 'override'
+     | 'pure'
+     | 'ref'
+     | '__gshared'
+     | 'scope'
+     | 'static'
+     | 'synchronized'
+     ;


+ +
+
StructBody parseStructBody(); +
+
Parses a StructBody +

+
 structBody:
+     '{' declaration* '}'
+     ;


+ +
+
StructDeclaration parseStructDeclaration(); +
+
Parses a StructDeclaration +

+
 structDeclaration:
+     'struct' Identifier? (templateParameters constraint? structBody | (structBody | ';'))
+     ;


+ +
+
StructInitializer parseStructInitializer(); +
+
Parses an StructInitializer +

+
 structInitializer:
+     '{' structMemberInitializers? '}'
+     ;


+ +
+
StructMemberInitializer parseStructMemberInitializer(); +
+
Parses a StructMemberInitializer +

+
 structMemberInitializer:
+     (Identifier ':')? nonVoidInitializer
+     ;


+ +
+
StructMemberInitializers parseStructMemberInitializers(); +
+
Parses StructMemberInitializers +

+
 structMemberInitializers:
+     structMemberInitializer (',' structMemberInitializer?)*
+     ;


+ +
+
SwitchStatement parseSwitchStatement(); +
+
Parses a SwitchStatement +

+
 switchStatement:
+     'switch' '(' expression ')' statement
+     ;


+ +
+
Symbol parseSymbol(); +
+
Parses a Symbol +

+
 symbol:
+     '.'? identifierOrTemplateChain
+     ;


+ +
+
SynchronizedStatement parseSynchronizedStatement(); +
+
Parses a SynchronizedStatement +

+
 synchronizedStatement:
+     'synchronized' ('(' expression ')')? statementNoCaseNoDefault
+     ;


+ +
+
TemplateAliasParameter parseTemplateAliasParameter(); +
+
Parses a TemplateAliasParameter +

+
 templateAliasParameter:
+     'alias' type? Identifier (':' (type | assignExpression))? ('=' (type | assignExpression))?
+     ;


+ +
+
TemplateArgument parseTemplateArgument(); +
+
Parses a TemplateArgument +

+
 templateArgument:
+       type
+     | assignExpression
+     ;


+ +
+
TemplateArgumentList parseTemplateArgumentList(); +
+
Parses a TemplateArgumentList +

+
 templateArgumentList:
+     templateArgument (',' templateArgument?)*
+     ;


+ +
+
TemplateArguments parseTemplateArguments(); +
+
Parses TemplateArguments +

+
 templateArguments:
+     '!' ('(' templateArgumentList? ')' | templateSingleArgument)
+     ;


+ +
+
TemplateDeclaration parseTemplateDeclaration(); +
+
Parses a TemplateDeclaration +

+
 templateDeclaration:
+       'template' Identifier templateParameters constraint? '{' declaration* '}'
+     | eponymousTemplateDeclaration
+     ;


+ +
+
EponymousTemplateDeclaration parseEponymousTemplateDeclaration(); +
+
Parses an EponymousTemplateDeclaration +

+
 eponymousTemplateDeclaration:
+     'enum' Identifier templateParameters '=' assignExpression ';'
+     ;


+ +
+
TemplateInstance parseTemplateInstance(); +
+
Parses a TemplateInstance +

+
 templateInstance:
+     Identifier templateArguments
+     ;


+ +
+
TemplateMixinExpression parseTemplateMixinExpression(); +
+
Parses a TemplateMixinExpression +

+
 templateMixinExpression:
+     'mixin' mixinTemplateName templateArguments? Identifier?
+     ;


+ +
+
TemplateParameter parseTemplateParameter(); +
+
Parses a TemplateParameter +

+
 templateParameter:
+       templateTypeParameter
+     | templateValueParameter
+     | templateAliasParameter
+     | templateTupleParameter
+     | templateThisParameter
+     ;


+ +
+
TemplateParameterList parseTemplateParameterList(); +
+
Parses an TemplateParameterList +

+
 templateParameterList:
+     templateParameter (',' templateParameter?)*
+     ;


+ +
+
TemplateParameters parseTemplateParameters(); +
+
Parses TemplateParameters +

+
 templateParameters:
+     '(' templateParameterList? ')'
+     ;


+ +
+
TemplateSingleArgument parseTemplateSingleArgument(); +
+
Parses a TemplateSingleArgument +

+
 templateSingleArgument:
+       builtinType
+     | Identifier
+     | CharacterLiteral
+     | StringLiteral
+     | IntegerLiteral
+     | FloatLiteral
+     | 'true'
+     | 'false'
+     | 'null'
+     | 'this'
+     | '__DATE__'
+     | '__TIME__'
+     | '__TIMESTAMP__'
+     | '__VENDOR__'
+     | '__VERSION__'
+     | '__FILE__'
+     | '__LINE__'
+     | '__MODULE__'
+     | '__FUNCTION__'
+     | '__PRETTY_FUNCTION__'
+     ;


+ +
+
TemplateThisParameter parseTemplateThisParameter(); +
+
Parses a TemplateThisParameter +

+
 templateThisParameter:
+     'this' templateTypeParameter
+     ;


+ +
+
TemplateTupleParameter parseTemplateTupleParameter(); +
+
Parses an TemplateTupleParameter +

+
 templateTupleParameter:
+     Identifier '...'
+     ;


+ +
+
TemplateTypeParameter parseTemplateTypeParameter(); +
+
Parses a TemplateTypeParameter +

+
 templateTypeParameter:
+     Identifier (':' type)? ('=' type)?
+     ;


+ +
+
TemplateValueParameter parseTemplateValueParameter(); +
+
Parses a TemplateValueParameter +

+
 templateValueParameter:
+     type Identifier (':' expression)? templateValueParameterDefault?
+     ;


+ +
+
TemplateValueParameterDefault parseTemplateValueParameterDefault(); +
+
Parses a TemplateValueParameterDefault +

+
 templateValueParameterDefault:
+     '=' ('__FILE__' | '__MODULE__' | '__LINE__' | '__FUNCTION__' | '__PRETTY_FUNCTION__' | assignExpression)
+     ;


+ +
+
ExpressionNode parseTernaryExpression(); +
+
Parses a TernaryExpression +

+
 ternaryExpression:
+     orOrExpression ('?' expression ':' ternaryExpression)?
+     ;


+ +
+
ThrowStatement parseThrowStatement(); +
+
Parses a ThrowStatement +

+
 throwStatement:
+     'throw' expression ';'
+     ;


+ +
+
TraitsExpression parseTraitsExpression(); +
+
Parses an TraitsExpression +

+
 traitsExpression:
+     '__traits' '(' Identifier ',' TemplateArgumentList ')'
+     ;


+ +
+
TryStatement parseTryStatement(); +
+
Parses a TryStatement +

+
 tryStatement:
+     'try' declarationOrStatement (catches | catches finally | finally)
+     ;


+ +
+
Type parseType(); +
+
Parses a Type +

+
 type:
+     attribute? type2 typeSuffix*
+     ;


+ +
+
Type2 parseType2(); +
+
Parses a Type2 +

+
 type2:
+       builtinType
+     | symbol
+     | typeofExpression ('.' identifierOrTemplateChain)?
+     | typeConstructor '(' type ')'
+     ;


+ +
+
IdType parseTypeConstructor(bool validate = true); +
+
Parses a TypeConstructor +

+
 typeConstructor:
+       'const'
+     | 'immutable'
+     | 'inout'
+     | 'shared'
+     | 'scope'
+     ;


+ +
+
IdType[] parseTypeConstructors(); +
+
Parses TypeConstructors +

+
 typeConstructors:
+     typeConstructor+
+     ;


+ +
+
TypeSpecialization parseTypeSpecialization(); +
+
Parses a TypeSpecialization +

+
 typeSpecialization:
+       type
+     | 'struct'
+     | 'union'
+     | 'class'
+     | 'interface'
+     | 'enum'
+     | 'function'
+     | 'delegate'
+     | 'super'
+     | 'const'
+     | 'immutable'
+     | 'inout'
+     | 'shared'
+     | 'return'
+     | 'typedef'
+     | '__parameters'
+     ;


+ +
+
TypeSuffix parseTypeSuffix(); +
+
Parses a TypeSuffix +

+
 typeSuffix:
+       '*'
+     | '[' type? ']'
+     | '[' assignExpression ']'
+     | '[' assignExpression '..'  assignExpression ']'
+     | ('delegate' | 'function') parameters memberFunctionAttribute*
+     ;


+ +
+
TypeidExpression parseTypeidExpression(); +
+
Parses a TypeidExpression +

+
 typeidExpression:
+     'typeid' '(' (type | expression) ')'
+     ;


+ +
+
TypeofExpression parseTypeofExpression(); +
+
Parses a TypeofExpression +

+
 typeofExpression:
+     'typeof' '(' (expression | 'return') ')'
+     ;


+ +
+
UnaryExpression parseUnaryExpression(); +
+
Parses a UnaryExpression +

+
 unaryExpression:
+       primaryExpression
+     | '&' unaryExpression
+     | '!' unaryExpression
+     | '*' unaryExpression
+     | '+' unaryExpression
+     | '-' unaryExpression
+     | '~' unaryExpression
+     | '++' unaryExpression
+     | '--' unaryExpression
+     | newExpression
+     | deleteExpression
+     | castExpression
+     | assertExpression
+     | functionCallExpression
+     | sliceExpression
+     | indexExpression
+     | '$LPAREN' type '$RPAREN' '.' identifierOrTemplateInstance
+     | unaryExpression '.' identifierOrTemplateInstance
+     | unaryExpression '--'
+     | unaryExpression '++'
+     ;


+ +
+
UnionDeclaration parseUnionDeclaration(); +
+
Parses an UnionDeclaration +

+
 unionDeclaration:
+       'union' Identifier templateParameters constraint? structBody
+     | 'union' Identifier (structBody | ';')
+     | 'union' structBody
+     ;


+ +
+
Unittest parseUnittest(); +
+
Parses a Unittest +

+
 unittest:
+     'unittest' blockStatement
+     ;


+ +
+
VariableDeclaration parseVariableDeclaration(Type type = null, bool isAuto = false); +
+
Parses a VariableDeclaration +

+
 variableDeclaration:
+       type declarator (',' declarator)* ';'
+     | autoDeclaration
+     ;


+ +
+
Vector parseVector(); +
+
Parses a Vector +

+
 vector:
+     '__vector' '(' type ')'
+     ;


+ +
+
VersionCondition parseVersionCondition(); +
+
Parses a VersionCondition +

+
 versionCondition:
+     'version' '(' (IntegerLiteral | Identifier | 'unittest' | 'assert') ')'
+     ;


+ +
+
VersionSpecification parseVersionSpecification(); +
+
Parses a VersionSpecification +

+
 versionSpecification:
+     'version' '=' (Identifier | IntegerLiteral) ';'
+     ;


+ +
+
WhileStatement parseWhileStatement(); +
+
Parses a WhileStatement +

+
 whileStatement:
+     'while' '(' expression ')' declarationOrStatement
+     ;


+ +
+
WithStatement parseWithStatement(); +
+
Parses a WithStatement +

+
 withStatement:
+     'with' '(' expression ')' statementNoCaseNoDefault
+     ;


+ +
+
ExpressionNode parseXorExpression(); +
+
Parses an XorExpression +

+
 xorExpression:
+       andExpression
+     | xorExpression '^' andExpression
+     ;


+ +
+
uint errorCount; +
+
Current error count

+ +
+
uint warningCount; +
+
Current warning count

+ +
+
string fileName; +
+
Name used when reporting warnings and errors

+ +
+
void function(string, size_t, size_t, string, bool) messageFunction; +
+
Function that is called when a warning or error is encountered. + The parameters are the file name, line number, column number, + and the error or warning message.

+ +
+
protected const(Token)* expect(IdType type); +
+
Returns a token of the specified type if it was the next token, otherwise + calls the error function and returns null.

+ +
+
protected const @property Token current(); +
+
Returns:
+the current token

+ +
+
protected Token advance(); +
+
Advances to the next token and returns the current token

+ +
+
protected const bool currentIs(IdType type); +
+
Returns:
+true if the current token has the given type

+ +
+
protected const bool currentIsOneOf(IdType[] types...); +
+
Returns:
+true if the current token is one of the given types

+ +
+
protected const nothrow bool moreTokens(); +
+
Returns:
+true if there are more tokens

+ +
+
+
+
+ +
Page generated by Ddoc. + diff --git a/stdx/d/parser.o b/stdx/d/parser.o new file mode 100644 index 0000000..b721184 Binary files /dev/null and b/stdx/d/parser.o differ