dparse.parser

Types 4

aliasMessageFunction = void function(string fileName , size_t line, size_t column, string message, bool isError)

Prototype for a custom parser message function or delegate. Parameters passed are a file name, a line, a column, a message and a bool that indicates if the message is a warning (false) or a if it's an error (true).

aliasMessageDelegate = void delegate(string, size_t, size_t, string, bool)

ditto

Parser configuration struct

Fields
const(Token)[] tokensThe tokens parsed by dparse.lexer.
string fileNameThe name of the file being parsed
RollbackAllocator * allocatorA pointer to a rollback allocator.
MessageFunction messageFunctionAn optional function used to handle warnings and errors.
MessageDelegate messageDelegateAn optional delegate used to handle warnings and errors. Set either this one or messageFunction, not both.
uint * errorCountAn optional pointer to a variable receiving the error count.
uint * warningCountAn optional pointer to a variable receiving the warning count.
classParser

D Parser.

It is sometimes useful to sub-class Parser to skip over things that are not interesting. For example, DCD skips over function bodies when caching symbols from imported files.

Fields
private TemplateArgumentParse
uint errorCountCurrent error count
uint warningCountCurrent warning count
string fileNameName used when reporting warnings and errors
const(Token)[] tokensTokens to parse
RollbackAllocator * allocatorAllocator used for creating AST nodes
MessageFunction messageFunctionFunction or delegate 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.
MessageDelegate messageDelegateDitto
MAX_ERRORS
string[] REGISTER_NAMES
TypedStackBuffer!uint suppressMessages
size_t index
int _traceDepth
string comment
bool[typeof(Token.index)] cachedAAChecks
bool[typeof(Token.index)] cachedTypeChecks
Methods
ExpressionNode parseAddExpression()Parses an AddExpression.
AliasDeclaration parseAliasDeclaration()Parses an AliasDeclaration.
AliasAssign parseAliasAssign()Parses an AliasAssign.
AliasInitializer parseAliasInitializer()Parses an AliasInitializer.
AliasThisDeclaration parseAliasThisDeclaration()Parses an AliasThisDeclaration.
AlignAttribute parseAlignAttribute()Parses an AlignAttribute.
ExpressionNode parseAndAndExpression()Parses an AndAndExpression.
ExpressionNode parseAndExpression()Parses an AndExpression.
NamedArgument parseNamedArgument()Parses a NamedArgument.
NamedArgumentList parseNamedArgumentList()Parses a NamedArgumentList.
ArgumentList parseArgumentList()Parses an ArgumentList.
Arguments parseArguments()Parses Arguments.
ArrayInitializer parseArrayInitializer()Parses an ArrayInitializer.
ArrayLiteral parseArrayLiteral()Parses an ArrayLiteral.
ArrayMemberInitialization parseArrayMemberInitialization()Parses an ArrayMemberInitialization.
ExpressionNode parseAsmAddExp()Parses an AsmAddExp
ExpressionNode parseAsmAndExp()Parses an AsmAndExp
AsmBrExp parseAsmBrExp()Parses an AsmBrExp
ExpressionNode parseAsmEqualExp()Parses an AsmEqualExp
ExpressionNode parseAsmExp()Parses an AsmExp
AsmInstruction parseAsmInstruction(ref bool maybeGccASm)Parses an AsmInstruction
ExpressionNode parseAsmLogAndExp()Parses an AsmLogAndExp
ExpressionNode parseAsmLogOrExp()Parses an AsmLogOrExp
ExpressionNode parseAsmMulExp()Parses an AsmMulExp
ExpressionNode parseAsmOrExp()Parses an AsmOrExp
AsmPrimaryExp parseAsmPrimaryExp()Parses an AsmPrimaryExp
ExpressionNode parseAsmRelExp()Parses an AsmRelExp
ExpressionNode parseAsmShiftExp()Parses an AsmShiftExp
AsmStatement parseAsmStatement()Parses an AsmStatement
AsmTypePrefix parseAsmTypePrefix()Parses an AsmTypePrefix
AsmUnaExp parseAsmUnaExp()Parses an AsmUnaExp
ExpressionNode parseAsmXorExp()Parses an AsmXorExp
AssertArguments parseAssertArguments()Parses an AssertArguments
AssertExpression parseAssertExpression()Parses an AssertExpression
ExpressionNode parseAssignExpression()Parses an AssignExpression
AssocArrayLiteral parseAssocArrayLiteral()Parses an AssocArrayLiteral
AtAttribute parseAtAttribute()Parses an AtAttribute
Attribute parseAttribute()Parses an Attribute
AttributeDeclaration parseAttributeDeclaration(Attribute attribute = null)Parses an AttributeDeclaration
AutoDeclaration parseAutoDeclaration()Parses an AutoDeclaration
AutoDeclarationPart parseAutoDeclarationPart()Parses an AutoDeclarationPart
BlockStatement parseBlockStatement()Parses a BlockStatement
BreakStatement parseBreakStatement()Parses a BreakStatement
BaseClass parseBaseClass()Parses a BaseClass
BaseClassList parseBaseClassList()Parses a BaseClassList
IdType parseBuiltinType()Parses an BuiltinType
CaseRangeStatement parseCaseRangeStatement(ExpressionNode low, size_t startIndex = - 1)Parses a CaseRangeStatement
CaseStatement parseCaseStatement(ArgumentList argumentList = null, size_t startIndex = - 1)Parses an CaseStatement
CastExpression parseCastExpression()Parses a CastExpression
CastQualifier parseCastQualifier()Parses a CastQualifier
Catch parseCatch()Parses a Catch
Catches parseCatches()Parses a Catches
ClassDeclaration parseClassDeclaration()Parses a ClassDeclaration
ExpressionNode parseCmpExpression()Parses a CmpExpression
CompileCondition parseCompileCondition()Parses a CompileCondition
ConditionalDeclaration parseConditionalDeclaration(bool strict, bool inTemplateDeclaration = false)Parses a ConditionalDeclaration
ConditionalStatement parseConditionalStatement()Parses a ConditionalStatement
Constraint parseConstraint()Parses a Constraint
Constructor parseConstructor()Parses a Constructor
ContinueStatement parseContinueStatement()Parses an ContinueStatement
DebugCondition parseDebugCondition()Parses a DebugCondition
DebugSpecification parseDebugSpecification()Parses a DebugSpecification
Declaration parseDeclaration(bool strict = false, bool mustBeDeclaration = false, bool inTemplateDeclaration = false)Parses a Declaration
DeclarationsAndStatements parseDeclarationsAndStatements(bool includeCases = true)Parses DeclarationsAndStatements
DeclarationOrStatement parseDeclarationOrStatement()Parses a DeclarationOrStatement
Declarator parseDeclarator()Parses a Declarator
DeclaratorIdentifierList parseDeclaratorIdentifierList()Parses a DeclaratorIdentifierList
BitfieldWidth parseBitfieldWidth()Parses a BitfieldWidth
DefaultStatement parseDefaultStatement()Parses a DefaultStatement
DeleteExpression parseDeleteExpression()Parses a DeleteExpression
Deprecated parseDeprecated()Parses a Deprecated attribute
Destructor parseDestructor()Parses a Destructor
DoStatement parseDoStatement()Parses a DoStatement
EnumBody parseEnumBody()Parses an EnumBody
AnonymousEnumMember parseAnonymousEnumMember(bool typeAllowed)anonymousEnumMember: type identifier '=' assignExpression | identifier '=' assignExpression | identifier ;
AnonymousEnumDeclaration parseAnonymousEnumDeclaration()anonymousEnumDeclaration: 'enum' (':' type? '{' anonymousEnumMember+ '}' ;)
EnumDeclaration parseEnumDeclaration()Parses an EnumDeclaration
EnumMemberAttribute parseEnumMemberAttribute()Parses an EnumMemberAttribute
EnumMember parseEnumMember()Parses an EnumMember
EponymousTemplateDeclaration parseEponymousTemplateDeclaration()Parses an EponymousTemplateDeclaration
EqualExpression parseEqualExpression(ExpressionNode shift = null)Parses an EqualExpression
Expression parseExpression()Parses an Expression
ExpressionStatement parseExpressionStatement(Expression expression = null)Parses an ExpressionStatement
FinalSwitchStatement parseFinalSwitchStatement()Parses a FinalSwitchStatement
Finally parseFinally()Parses a Finally
ForStatement parseForStatement()Parses a ForStatement
StaticForeachDeclaration parseStaticForeachDeclaration(bool inTemplateDeclaration = false)Parses a StaticForeachDeclaration
StaticForeachStatement parseStaticForeachStatement()Parses a StaticForeachStatement
ForeachStatement parseForeachStatement()Parses a ForeachStatement
Foreach!declOnly parseForeach(bool declOnly = false)(bool inTemplateDeclaration = false)
ForeachType parseForeachType()Parses a ForeachType
ForeachTypeList parseForeachTypeList()Parses a ForeachTypeList
FunctionAttribute parseFunctionAttribute(bool validate = true)Parses a FunctionAttribute
FunctionBody parseFunctionBody()Parses a FunctionBody. Note that any change of this function must also be applied in dsymbol SimpleParser, which can be found https://github.com/dlang-community/dsymbol/blob/master/src/dsymbol/conv...
FunctionCallExpression parseFunctionCallExpression(UnaryExpression unary = null)Parses a FunctionCallExpression
FunctionContract parseFunctionContract(bool allowStatement = true)Parses a FunctionContract
FunctionDeclaration parseFunctionDeclaration(Type type = null, bool isAuto = false, Attribute[] attributes = null)Parses a FunctionDeclaration
FunctionLiteralExpression parseFunctionLiteralExpression()Parses a FunctionLiteralExpression
GccAsmInstruction parseGccAsmInstruction()Parses an AsmInstruction using GCC Assembler
GccAsmOperandList parseGccAsmOperandList()Parses a GccAsmOperandList
GccAsmOperand parseGccAsmOperand()Parses a GccAsmOperand
GotoStatement parseGotoStatement()Parses a GotoStatement
IdentifierChain parseIdentifierChain()Parses an IdentifierChain
TypeIdentifierPart parseTypeIdentifierPart()Parses a TypeIdentifierPart.
IdentifierOrTemplateChain parseIdentifierOrTemplateChain()Parses an IdentifierOrTemplateChain
IdentifierOrTemplateInstance parseIdentifierOrTemplateInstance()Parses an IdentifierOrTemplateInstance
ExpressionNode parseIdentityExpression(ExpressionNode shift = null)Parses an IdentityExpression
IfStatement parseIfStatement()Parses an IfStatement
IfCondition parseIfCondition()Parses an IfCondition
ImportBind parseImportBind()Parses an ImportBind
ImportBindings parseImportBindings(SingleImport singleImport)Parses ImportBindings
ImportDeclaration parseImportDeclaration()Parses an ImportDeclaration
ImportExpression parseImportExpression()Parses an ImportExpression
Index parseIndex()Parses an Index
IndexExpression parseIndexExpression(UnaryExpression unaryExpression = null)Parses an IndexExpression
InContractExpression parseInContractExpression()Parses an InContractExpression
ExpressionNode parseInExpression(ExpressionNode shift = null)Parses an InExpression
InOutContractExpression parseInOutContractExpression()Parses an InOutContractExpression
InOutStatement parseInOutStatement()Parses an InOutStatement
InStatement parseInStatement()Parses an InStatement
Initializer parseInitializer()Parses an Initializer
InterfaceDeclaration parseInterfaceDeclaration()Parses an InterfaceDeclaration
InterpolatedString parseInterpolatedString()Parses an InterpolatedString
InterpolatedStringPart parseInterpolatedStringPart()Parses an InterpolatedStringPart
Invariant parseInvariant()Parses an Invariant
IsExpression parseIsExpression()Parses an IsExpression
KeyValuePair parseKeyValuePair()Parses a KeyValuePair
KeyValuePairs parseKeyValuePairs()Parses KeyValuePairs
LabeledStatement parseLabeledStatement()Parses a LabeledStatement
LastCatch parseLastCatch()Parses a LastCatch
LinkageAttribute parseLinkageAttribute()Parses a LinkageAttribute
MemberFunctionAttribute parseMemberFunctionAttribute()Parses a MemberFunctionAttribute
MissingFunctionBody parseMissingFunctionBody()Parses a MissingFunctionBody
MixinDeclaration parseMixinDeclaration()Parses a MixinDeclaration
MixinExpression parseMixinExpression()Parses a MixinExpression
MixinTemplateDeclaration parseMixinTemplateDeclaration()Parses a MixinTemplateDeclaration
MixinTemplateName parseMixinTemplateName()Parses a MixinTemplateName
Module parseModule()Parses a Module
ModuleDeclaration parseModuleDeclaration()Parses a ModuleDeclaration
ExpressionNode parseMulExpression()Parses a MulExpression.
NamespaceList parseNamespaceList()Parses a NamespaceList.
NewAnonClassExpression parseNewAnonClassExpression()Parses a NewAnonClassExpression
NewExpression parseNewExpression()Parses a NewExpression
NonVoidInitializer parseNonVoidInitializer()Parses a NonVoidInitializer
Operands parseOperands()Parses Operands
ExpressionNode parseOrExpression()Parses an OrExpression
ExpressionNode parseOrOrExpression()Parses an OrOrExpression
OutContractExpression parseOutContractExpression()Parses an OutContractExpression
OutStatement parseOutStatement()Parses an OutStatement
Parameter parseParameter()Parses a Parameter
ParameterAttribute parseParameterAttribute(bool validate = false)Parses a ParameterAttribute
Parameters parseParameters()Parses Parameters
ParameterAttribute[] parseVariadicArgumentsAttributes()Parses attributes of C-style variadic parameters.
ParameterAttribute parseVariadicArgumentsAttribute()Parses an attribute of C-style variadic parameters.
Postblit parsePostblit()Parses a Postblit
ExpressionNode parsePowExpression()Parses a PowExpression
PragmaDeclaration parsePragmaDeclaration()Parses a PragmaDeclaration
PragmaExpression parsePragmaExpression()Parses a PragmaExpression
PragmaStatement parsePragmaStatement()Parses a PragmaStatement
PrimaryExpression parsePrimaryExpression()Parses a PrimaryExpression
Register parseRegister()Parses a Register
ExpressionNode parseRelExpression(ExpressionNode shift)Parses a RelExpression
ReturnStatement parseReturnStatement()Parses a ReturnStatement
ScopeGuardStatement parseScopeGuardStatement()Parses a ScopeGuardStatement
SharedStaticConstructor parseSharedStaticConstructor()Parses a SharedStaticConstructor
SharedStaticDestructor parseSharedStaticDestructor()Parses a SharedStaticDestructor
ExpressionNode parseShiftExpression()Parses a ShiftExpression
SingleImport parseSingleImport()Parses a SingleImport
ShortenedFunctionBody parseShortenedFunctionBody()Parses a ShortenedFunctionBody
SpecifiedFunctionBody parseSpecifiedFunctionBody()Parses a SpecifiedFunctionBody
Statement parseStatement()Parses a Statement
StatementNoCaseNoDefault parseStatementNoCaseNoDefault()Parses a StatementNoCaseNoDefault
StaticAssertDeclaration parseStaticAssertDeclaration()Parses a StaticAssertDeclaration
StaticAssertStatement parseStaticAssertStatement()Parses a StaticAssertStatement
StaticConstructor parseStaticConstructor()Parses a StaticConstructor
StaticDestructor parseStaticDestructor()Parses a StaticDestructor
StaticIfCondition parseStaticIfCondition()Parses an StaticIfCondition
StorageClass parseStorageClass()Parses a StorageClass
private StringLiteralList parseStringLiteralList()Parses a StringLiteralList
StructBody parseStructBody()Parses a StructBody
StructDeclaration parseStructDeclaration()Parses a StructDeclaration
StructInitializer parseStructInitializer()Parses an StructInitializer
StructMemberInitializer parseStructMemberInitializer()Parses a StructMemberInitializer
SwitchStatement parseSwitchStatement()Parses a SwitchStatement
Symbol parseSymbol()Parses a Symbol
SynchronizedStatement parseSynchronizedStatement()Parses a SynchronizedStatement
TemplateAliasParameter parseTemplateAliasParameter()Parses a TemplateAliasParameter
NamedTemplateArgument parseNamedTemplateArgument()Parses a NamedTemplateArgument
TemplateArgument parseTemplateArgument()Parses a TemplateArgument
TemplateArgumentList parseTemplateArgumentList()Parses a TemplateArgumentList
NamedTemplateArgumentList parseNamedTemplateArgumentList()Parses a NamedTemplateArgumentList
TemplateArguments parseTemplateArguments()Parses TemplateArguments
TemplateDeclaration parseTemplateDeclaration()Parses a TemplateDeclaration
TemplateInstance parseTemplateInstance()Parses a TemplateInstance
TemplateMixinExpression parseTemplateMixinExpression()Parses a TemplateMixinExpression
TemplateParameter parseTemplateParameter()Parses a TemplateParameter
TemplateParameterList parseTemplateParameterList()Parses a TemplateParameterList
TemplateParameters parseTemplateParameters()Parses TemplateParameters
TemplateSingleArgument parseTemplateSingleArgument()Parses a TemplateSingleArgument
TemplateThisParameter parseTemplateThisParameter()Parses a TemplateThisParameter
TemplateTupleParameter parseTemplateTupleParameter()Parses an TemplateTupleParameter
TemplateTypeParameter parseTemplateTypeParameter()Parses a TemplateTypeParameter
TemplateValueParameter parseTemplateValueParameter()Parses a TemplateValueParameter
ExpressionNode parseTernaryExpression()Parses a TernaryExpression
ThrowExpression parseThrowExpression()Parses a ThrowExpression
TraitsExpression parseTraitsExpression()Parses an TraitsExpression
TryStatement parseTryStatement()Parses a TryStatement
Type parseType()Parses a Type
Type2 parseType2()Parses a Type2
IdType parseTypeConstructor(bool validate = true)Parses a TypeConstructor
IdType[] parseTypeConstructors()Parses TypeConstructors
TypeSpecialization parseTypeSpecialization()Parses a TypeSpecialization
TypeSuffix parseTypeSuffix()Parses a TypeSuffix
TypeidExpression parseTypeidExpression()Parses a TypeidExpression
TypeofExpression parseTypeofExpression()Parses a TypeofExpression
UnaryExpression parseUnaryExpression()Parses a UnaryExpression
UnionDeclaration parseUnionDeclaration()Parses an UnionDeclaration
Unittest parseUnittest()Parses a Unittest
VariableDeclaration parseVariableDeclaration(Type type = null, bool isAuto = false)Parses a VariableDeclaration
Vector parseVector()Parses a Vector
VersionCondition parseVersionCondition()Parses a VersionCondition
VersionSpecification parseVersionSpecification()Parses a VersionSpecification
WhileStatement parseWhileStatement()Parses a WhileStatement
WithStatement parseWithStatement()Parses a WithStatement
ExpressionNode parseXorExpression()Parses an XorExpression
void setTokens(const(Token)[] tokens)
bool moreTokens() const nothrow pure @safe @nogcReturns: true if there are more tokens
void ownArray(T)(ref T[] arr, ref StackBuffer sb)
bool isCastQualifier() const
bool hasMagicDelimiter(alias L, alias T)()
DecType isAutoDeclaration(ref size_t beginIndex) nothrow @safe
bool isType()Only use this in template parameter parsing
bool isMemberFunctionAttribute(IdType t) pure nothrow @nogc @safe
bool isTypeCtor(IdType t) pure nothrow @nogc @safe
void moveStartIndexBefore(ref size_t startIndex, const BaseNode child, string func = __FUNCTION__)
ExpressionNode parseLeftAssocBinaryExpression(alias ExpressionType, alias ExpressionPartType, Operators ...)(ExpressionNode part = null)
ListType parseCommaSeparatedRule(alias ListType, alias ItemType, bool setLineAndColumn = false)(bool allowTrailingComma = false)
void warn(lazy string message)
void error(string message, bool shouldAdvance = true, bool includeCurrentToken = false)
bool skip(IdType token)Skips token if present and returns whether token was skipped
void skip(alias O, alias C)()
void skipBraces() pure nothrow @safe @nogc
void skipParens() pure nothrow @safe @nogc
void skipBrackets() pure nothrow @safe @nogc
const(Token) * peek() const pure nothrow @safe @nogcReturns: a pointer to the token after the current one, or `null` if there is none.
const(Token) * peekPast(alias O, alias C)() const pure nothrow @safe @nogc
const(Token) * peekPastParens() const pure nothrow @safe @nogcReturns: a pointer to the token after a set of balanced parenthesis, or `null` in the case that the current token is not an opening parenthesis or an end of file is reached before a closing parenth...
const(Token) * peekPastBrackets() const pure nothrow @safe @nogcSee_also: peekPastParens
const(Token) * peekPastBraces() const pure nothrow @safe @nogcSee_also: peekPastParens
bool peekIs(IdType t) const pure nothrow @safe @nogcReturns: `true` if there is a next token and that token has the type `t`.
bool peekNIs(IdType t, size_t offset) const pure nothrow @safe @nogcReturns: `true` if the token `offset` tokens ahead exists and is of type `t`.
bool peekAre(IdType[] types...) const pure nothrow @safe @nogcReturns: `true` if there are at least `types.length` tokens following the current one and they have types matching the corresponding elements of `types`.
bool peekIsOneOf(IdType[] types...) const pure nothrow @safe @nogcReturns: `true` if there is a next token and its type is one of the given `types`.
bool peekNIsOneOf(size_t offset, IdType[] types...) const pure nothrow @safe @nogcReturns: `true` if there is a token `offset` tokens after the current one and its type is one of the given `types`.
const(Token) * expect(IdType type)Returns: a pointer to a token of the specified type if it was the next token, otherwise calls the error function and returns null.
Token current() const pure nothrow @safe @nogc @propertyReturns: the current token
Token previous() const pure nothrow @safe @nogc @propertyReturns: the previous token
Token advance() pure nothrow @nogc @safeAdvances to the next token and returns the current token
bool currentIs(IdType type) const pure nothrow @safe @nogcReturns: true if the current token has the given type
bool currentIsOneOf(IdType[] types...) const pure nothrow @safe @nogcReturns: true if the current token is one of the given types
bool startsWith(IdType[] types...) const pure nothrow @safe @nogcReturns: `true` if there are at least `types.length` tokens starting at the current token, and the tokens have types corresponding to the elements of `types`.
Bookmark setBookmark() nothrow @safe
void abandonBookmark(Bookmark) pure nothrow @safe @nogc
void goToBookmark(Bookmark bookmark, bool popStack = true) pure nothrow @safe @nogcGoes back to a parser bookmark and optionally invalidates it. Params: bookmark = bookmark to revert to popStack = if set to true, the bookmark is cleared, otherwise it must be manually cleared usin...
void attachComment(T)(T node, string comment)
T attachCommentFromSemicolon(T)(T node, size_t startIndex)
N parseStaticCtorDtorCommon(N)(N node, size_t startIndex)
N parseInterfaceOrClass(N)(N node, size_t startIndex)
uint suppressedErrorCount() const pure nothrow @nogc @safe
Nested Templates
DecType
simpleParse(NodeType, parts ...)
simpleParseItems(items ...)
simpleParseItem(alias item)
traceEnterAndExit(string fun)
parseNodeQ(string VarName, string NodeName)
nullCheck(string exp)
tokenCheck(string Tok)
tokenCheck(string Exp, string Tok)

Functions 3

fnModule parseModule()(auto ref ParserConfig parserConfig)Params: parserConfig = a parser configuration. Returns: The parsed module.
fnModule parseModule(F)(const(Token)[] tokens, string fileName, RollbackAllocator * allocator, F messageFuncOrDg = null, uint * errorCount = null, uint * warningCount = null)Params: tokens = The tokens parsed by dparse.lexer. fileName = The name of the file being parsed. allocator = A pointer to a rollback allocator. messageFuncOrDg = Either a function or a delegate th...