ImportParser

A light-weight parser which looks only for import statements in the source text.

class ImportParser : Parser {}

Inherited Members

From Parser

lexer
Lexer lexer;

Used to lex the source code.

token
Token* token;

Current non-whitespace token.

prevToken
Token* prevToken;

Previous non-whitespace token.

diag
Diagnostics diag;

Collects error messages.

errors
ParserError[] errors;

Array of parser error messages.

imports
ImportDecl[] imports;

ImportDeclarations in the source text.

linkageType
LinkageType linkageType;
protection
Protection protection;
storageClass
StorageClass storageClass;
alignSize
uint alignSize;

Attributes are evaluated in the parsing phase. TODO: will be removed. SemanticPass1 takes care of attributes.

init
void init()

Moves to the first non-whitespace token.

nT
void nT()

Moves to the next token.

start
CompoundDecl start()

Starts the parser and returns the parsed Declarations.

start2
Expression start2()

Starts the parser and returns the parsed Expression.

trying
uint trying;

Greater than 0 if Parser is in tryToParse().

errorCount
uint errorCount;

Used to track nr. of errors while being in tryToParse().

tryToParse
RetType tryToParse(RetType delegate() parseMethod, out bool success)

This method executes the delegate parseMethod and when an error occurs the state of the lexer and parser is restored.

fail_tryToParse
void fail_tryToParse()

Causes the current call to tryToParse() to fail.

backtrackTo
void backtrackTo(Token* newtok, Token* newprev = null)

Backtracks the Parser to the given token(s).

set
Class set(Class node, Token* begin)

Sets the begin and end tokens of a syntax tree node.

set
Class set(Class node, Token* begin, Token* end)

Sets the begin and end tokens of a syntax tree node.

isNodeSet
bool isNodeSet(const Node node)

Returns true if set() has been called on a node.

tokenIs
bool tokenIs()

Returns true if the current token is of kind T!str.

nextIs
bool nextIs()

Returns true if the next token is of kind T!str.

peekNext
TOK peekNext()

Returns the token kind of the next token.

peekAfter
Token* peekAfter(Token* t)

Returns the token that comes after t.

consume
Token* consume()

Consumes the current token and returns it.

consumed
bool consumed()

Consumes the current token if its kind matches T!str and returns true.

consumedToken
Token* consumedToken()

Consumes the current token if its kind matches T!str and returns it.

skip
void skip()

Asserts that the current token is of kind T!str, and then moves to the next token.

tokenAfterParenIs
bool tokenAfterParenIs(TOK kind)

Returns true if the token after the closing parenthesis matches the searched kind.

tokenAfterBracket
TOK tokenAfterBracket(TOK closing)

Returns the token kind behind the closing bracket.

skipParens
Token* skipParens(Token* peek_token, TOK closing)

Skips to the token behind the closing parenthesis token. Takes nesting into account.

parseModuleDecl
Declaration parseModuleDecl()

$(BNF ModuleDecl := module ModuleType? Identifier ("." Identifier)* ";" /ModuleType := "(" safe | system ")")

parseDeclarationDefinitions
Declaration[] parseDeclarationDefinitions()

Parses DeclarationDefinitions until the end of file is hit. $(BNF DeclDefs := DeclDef*)

parseDeclarationDefinitionsBody
CompoundDecl parseDeclarationDefinitionsBody()

Parse the body of a template, class, interface, struct or union. $(BNF DeclDefsBlock := "{" DeclDefs? "}")

parseDeclarationDefinition
Declaration parseDeclarationDefinition()

Parses a DeclarationDefinition.

parseDeclarationsBlock
Declaration parseDeclarationsBlock()

Parses a DeclarationsBlock. $(BNF DeclsBlock := ":" DeclDefs | "{" DeclDefs? "}" | DeclDef)

parseAliasDecl
Declaration parseAliasDecl()

$(BNF /AliasDecl := alias Attributes /AliasThisDecl := alias Identifier this ";" /AliasesDecl := alias AliasName "=" Type ("," AliasName "=" Type)* ";" /AliasName := this | Identifier)

parseVariablesOrFunction
Declaration parseVariablesOrFunction(StorageClass stcs = StorageClass.None, Protection protection = Protection.None, LinkageType linkType = LinkageType.None, bool testAutoDeclaration = false)

Parses either a VariablesDecl or a FunctionDecl.

parseInitializer
Expression parseInitializer()

Parses a variable initializer. $(BNF Initializer := VoidInitializer | NonVoidInitializer /VoidInitializer := void /NonVoidInitializer := / ArrayInitializer | StructInitializer | AssignExpr /ArrayInitializer := "[" ArrayInitElements? "]" /ArrayInitElements := ArrayInitElement ("," ArrayInitElement)* ","? /ArrayInitElement := (AssignExpr ":")? NonVoidInitializer /StructInitializer := "{" StructInitElements? "}" /StructInitElements := StructInitElement ("," StructInitElement)* ","? /StructInitElement := (MemberName ":")? NonVoidInitializer /MemberName := Identifier)

parseNonVoidInitializer
Expression parseNonVoidInitializer()

Parses a NonVoidInitializer. $(BNF NonVoidInitializer := / ArrayInitializer | StructInitializer | AssignExpr)

parseFunctionBody
FuncBodyStmt parseFunctionBody()

Parses the body of a function.

parseFunctionPostfix
StorageClass parseFunctionPostfix()

$(BNF FunctionPostfix := / (const|immutable|inout|nothrow|shared|pure| "@" Identifier)*)

FunctionPostfix
alias FunctionPostfix = Tuple!("const", "immutable", "inout", "nothrow", "shared", "pure", "@")

A tuple of all the possible postfix tokens.

parseExternLinkageType
LinkageType parseExternLinkageType()

$(BNF ExternLinkageType := extern "(" LinkageType ")" LinkageType := "C" | "C" "++" | "D" | "Windows" | "Pascal" | "System")

checkLinkageType
void checkLinkageType(ref LinkageType prev_lt, LinkageType lt, Token* begin)

Reports an error if a linkage type has already been parsed.

getSTC
StorageClass getSTC()

Returns a StorageClass when the next token is not a "(".

parseAttributes
Declaration parseAttributes(Declaration* pDecl = null)

Parses one or more attributes and a Declaration at the end.

parseAlignAttribute
uint parseAlignAttribute(out Token* sizetok)

$(BNF AlignAttribute := align ("(" Integer ")")?)

parseAtAttribute
StorageClass parseAtAttribute()

$(BNF AtAttribute := "@" Identifier)

parseImportDecl
ImportDecl parseImportDecl()

$(BNF ImportDecl := static? import / ImportModule ("," ImportModule)* / (":" ImportBind ("," ImportBind)*)? / ";" /ImportModule := (AliasName "=")? ModuleName /ImportBind := (AliasName "=")? BindName /ModuleName := Identifier ("." Identifier)* /AliasName := Identifier /BindName := Identifier)

isEnumManifest
bool isEnumManifest()

Returns true if this is an enum manifest or false if it's a normal enum declaration.

parseEnumDecl
Declaration parseEnumDecl()

$(BNF /EnumDecl := / enum Name? (":" BasicType)? EnumBody | / enum Name ";" /EnumBody := "{" EnumMembers "}" /EnumMembers := EnumMember ("," EnumMember)* ","? /EnumMembers2 := Type? EnumMember ("," Type? EnumMember)* ","? # D2.0 /EnumMember := Name ("=" AssignExpr)?)

putInsideTemplateDeclaration
TemplateDecl putInsideTemplateDeclaration(Token* begin, Token* name, Declaration decl, TemplateParameters tparams, Expression constraint)

Wraps a declaration inside a template declaration.

parseClassDecl
Declaration parseClassDecl()

$(BNF ClassDecl := / class Name TemplateParameterList? (":" BaseClasses) ClassBody | / class Name ";" /ClassBody := DeclDefsBlock)

parseBaseClasses
BaseClassType[] parseBaseClasses()

$(BNF BaseClasses := BaseClass ("," BaseClass)* /BaseClass := Protection? BasicType /Protection := private | public | protected | package)

parseInterfaceDecl
Declaration parseInterfaceDecl()

$(BNF InterfaceDecl := / interface Name TemplateParameterList? (":" BaseClasses) InterfaceBody | / interface Name ";" /InterfaceBody := DeclDefsBlock)

parseStructOrUnionDecl
Declaration parseStructOrUnionDecl()

$(BNF StructDecl := / struct Name? TemplateParameterList? StructBody | / struct Name ";" /StructBody := DeclDefsBlock /UnionDecl := / union Name? TemplateParameterList? UnionBody | / union Name ";" /UnionBody := DeclDefsBlock)

parseConstructorDecl
Declaration parseConstructorDecl()

$(BNF ConstructorDecl := this ParameterList FunctionBody)

parseDestructorDecl
Declaration parseDestructorDecl()

$(BNF DestructorDecl := "~" this "(" ")" FunctionBody)

parseStaticCtorDecl
Declaration parseStaticCtorDecl()

$(BNF StaticCtorDecl := static this "(" ")" FunctionBody)

parseStaticDtorDecl
Declaration parseStaticDtorDecl()

$(BNF /StaticDtorDecl := static "~" this "(" ")" FunctionBody)

parseInvariantDecl
Declaration parseInvariantDecl()

$(BNF InvariantDecl := invariant ("(" ")")? FunctionBody)

parseUnittestDecl
Declaration parseUnittestDecl()

$(BNF UnittestDecl := unittest FunctionBody)

parseIdentOrInt
Token* parseIdentOrInt()

Parses an identifier or an integer. Reports an error otherwise. $(BNF IdentOrInt := Identifier | Integer)

parseVersionCondition
Token* parseVersionCondition()

$(BNF VersionCondition := unittest #*D2.0*# | IdentOrInt)

parseDebugDecl
Declaration parseDebugDecl()

$(BNF DebugDecl := / debug "=" IdentOrInt ";" | / debug DebugCondition? DeclsBlock (else DeclsBlock)? /DebugCondition := "(" IdentOrInt ")")

parseVersionDecl
Declaration parseVersionDecl()

$(BNF VersionDecl := / version "=" IdentOrInt ";" | / version VCondition DeclsBlock (else DeclsBlock)? /VCondition := "(" VersionCondition ")")

parseStaticIfDecl
Declaration parseStaticIfDecl()

$(BNF StaticIfDecl := / static if "(" AssignExpr ")" DeclsBlock (else DeclsBlock)?)

parseStaticAssertDecl
Declaration parseStaticAssertDecl()

$(BNF StaticAssertDecl := / static assert "(" AssignExpr ("," Message)? ")" ";" /Message := AssignExpr)

parseTemplateDecl
TemplateDecl parseTemplateDecl()

$(BNF TemplateDecl := / template Name TemplateParameterList Constraint? DeclDefsBlock)

parseNewDecl
Declaration parseNewDecl()

$(BNF NewDecl := new ParameterList FunctionBody)

parseDeleteDecl
Declaration parseDeleteDecl()

$(BNF DeleteDecl := delete ParameterList FunctionBody)

parseMixin
RetT parseMixin()

Parses a MixinDecl or MixinStmt. $(BNF /MixinDecl := (MixinExpr | MixinTemplate | MixinTemplateId) ";" /MixinExpr := mixin "(" AssignExpr ")" /MixinTemplate := mixin TemplateDecl # D2 /MixinTemplateId := mixin TemplateIdentifier / ("!" "(" TemplateArguments ")")? MixinIdentifier?)

parseStatements
CompoundStmt parseStatements()

$(BNF Statements := "{" Statement* "}")

parseStatement
Statement parseStatement()

Parses a Statement.

parseScopeStmt
Statement parseScopeStmt()

Parses a ScopeStmt. $(BNF ScopeStmt := NoScopeStmt)

parseNoScopeStmt
Statement parseNoScopeStmt()

$(BNF /NoScopeStmt := NonEmptyStmt | BlockStmt /BlockStmt := Statements)

parseNoScopeOrEmptyStmt
Statement parseNoScopeOrEmptyStmt()

$(BNF NoScopeOrEmptyStmt := ";" | NoScopeStmt)

parseAttributeStmt
Statement parseAttributeStmt()

$(BNF AttributeStmt := Attributes+ / (VariableOrFunctionDecl | DeclDef) /Attributes := extern | ExternLinkageType | auto | static | / final | const | immutable | enum | scope)

parseIfStmt
Statement parseIfStmt()

$(BNF IfStmt := if "(" Condition ")" ScopeStmt (else ScopeStmt)? /Condition := AutoDecl | VariableDecl | Expression)

parseWhileStmt
Statement parseWhileStmt()

$(BNF WhileStmt := while "(" Expression ")" ScopeStmt)

parseDoWhileStmt
Statement parseDoWhileStmt()

$(BNF DoWhileStmt := do ScopeStmt while "(" Expression ")")

parseForStmt
Statement parseForStmt()

$(BNF ForStmt := / for "(" (NoScopeStmt | ";") Expression? ";" Expression? ")" / ScopeStmt)

parseForeachStmt
Statement parseForeachStmt()

$(BNF ForeachStmt := / Foreach "(" ForeachVarList ";" Aggregate ")" / ScopeStmt /Foreach := foreach | foreach_reverse /ForeachVarList := ForeachVar ("," ForeachVar)* /ForeachVar := ref? (Identifier | Declarator) /RangeExpr2 := Expression ".." Expression # D2 /Aggregate := RangeExpr2 | Expression)

parseSwitchStmt
Statement parseSwitchStmt()

$(BNF SwitchStmt := final? switch "(" Expression ")" ScopeStmt)

parseCaseOrDefaultBody
Statement parseCaseOrDefaultBody()

Helper function for parsing the body of a default or case statement. $(BNF CaseOrDefaultBody := ScopeStmt*)

parseCaseStmt
Statement parseCaseStmt()

$(BNF CaseStmt := case ExpressionList ":" CaseOrDefaultBody | / case AssignExpr ":" ".." case AssignExpr ":" CaseOrDefaultBody)

parseDefaultStmt
Statement parseDefaultStmt()

$(BNF DefaultStmt := default ":" CaseOrDefaultBody)

parseContinueStmt
Statement parseContinueStmt()

$(BNF ContinueStmt := continue Identifier? ";")

parseBreakStmt
Statement parseBreakStmt()

$(BNF BreakStmt := break Identifier? ";")

parseReturnStmt
Statement parseReturnStmt()

$(BNF ReturnStmt := return Expression? ";")

parseGotoStmt
Statement parseGotoStmt()

$(BNF /GotoStmt := goto (case Expression? | default | Identifier) ";")

parseWithStmt
Statement parseWithStmt()

$(BNF WithStmt := with "(" Expression ")" ScopeStmt)

parseSynchronizedStmt
Statement parseSynchronizedStmt()

$(BNF SynchronizedStmt := synchronized ("(" Expression ")")? ScopeStmt)

parseTryStmt
Statement parseTryStmt()

$(BNF TryStmt := try ScopeStmt CatchStmt* LastCatchStmt? FinallyStmt? /CatchStmt := catch "(" BasicType Identifier ")" NoScopeStmt /LastCatchStmt := catch NoScopeStmt /FinallyStmt := finally NoScopeStmt)

parseThrowStmt
Statement parseThrowStmt()

$(BNF ThrowStmt := throw Expression ";")

parseScopeGuardStmt
Statement parseScopeGuardStmt()

$(BNF ScopeGuardStmt := scope "(" ScopeCondition ")" ScopeGuardBody /ScopeCondition := "exit" | "success" | "failure" /ScopeGuardBody := ScopeStmt | NoScopeStmt)

parseVolatileStmt
Statement parseVolatileStmt()

$(BNF VolatileStmt := volatile (ScopeStmt | NoScopeStmt))

parsePragmaStmt
Statement parsePragmaStmt()

$(BNF PragmaStmt := / pragma "(" Identifier ("," ExpressionList)? ")" NoScopeStmt)

parseStaticIfStmt
Statement parseStaticIfStmt()

$(BNF StaticIfStmt := / static if "(" Expression ")" NoScopeStmt (else NoScopeStmt)?)

parseStaticAssertStmt
Statement parseStaticAssertStmt()

$(BNF StaticAssertStmt := / static assert "(" AssignExpr ("," Message)? ")" ";" /Message := AssignExpr)

parseDebugStmt
Statement parseDebugStmt()

$(BNF DebugStmt := / debug DebugCondition? NoScopeStmt (else NoScopeStmt)?)

parseVersionStmt
Statement parseVersionStmt()

$(BNF VersionStmt := / version VCondition NoScopeStmt (else NoScopeStmt)?)

parseAsmBlockStmt
Statement parseAsmBlockStmt()

Parses an AsmBlockStmt. $(BNF AsmBlockStmt := asm "{" AsmStmt* "}")

parseAsmStmt
Statement parseAsmStmt()

$(BNF /AsmStmt := / OpcodeStmt | LabeledStmt | AsmAlignStmt | EmptyStmt /OpcodeStmt := Opcode Operands? ";" /Opcode := Identifier /Operands := AsmExpr ("," AsmExpr)* /LabeledStmt := Identifier ":" AsmStmt /AsmAlignStmt := align Integer ";" /EmptyStmt := ";")

parseAsmExpr
Expression parseAsmExpr()

$(BNF AsmExpr := AsmCondExpr /AsmCondExpr := AsmBinaryExpr ("?" AsmExpr ":" AsmExpr)?)

parseAsmBinaryExpr
Expression parseAsmBinaryExpr(PREC prevPrec = PREC.None)

$(BNF AsmBinaryExpr := AsmOrOrExpr /AsmOrOrExpr := AsmAndAndExpr ("||" AsmAndAndExpr)* /AsmAndAndExpr := AsmOrExpr ("&&" AsmOrExpr)* /AsmOrExpr := AsmXorExpr ("|" AsmXorExpr)* /AsmXorExpr := AsmAndExpr ("^" AsmAndExpr)* /AsmAndExpr := AsmCmpExpr ("&" AsmCmpExpr)* /AsmCmpExpr := AsmShiftExpr (AsmCmpOp AsmShiftExpr)* /AsmCmpOp := "==" | "!=" | "<" | "<=" | ">" | ">=" /AsmShiftExpr := AsmAddExpr (AsmShiftOp AsmAddExpr)* /AsmShiftOp := "<<" | ">>" | ">>>" /AsmAddExpr := AsmMulExpr (AsmAddOp AsmMulExpr)* /AsmAddOp := "+" | "-" /AsmMulExpr := AsmPostExpr (AsmMulOp AsmPostExpr)* /AsmMulOp := "*" | "/" | "%" /)

parseAsmPostExpr
Expression parseAsmPostExpr()

$(BNF AsmPostExpr := AsmUnaryExpr ("[" AsmExpr "]")*)

parseAsmUnaryExpr
Expression parseAsmUnaryExpr()

$(BNF /AsmUnaryExpr := / AsmPrimaryExpr | AsmTypeExpr | AsmOffsetExpr | AsmSegExpr | / SignExpr | NotExpr | ComplementExpr /AsmTypeExpr := TypePrefix "ptr" AsmExpr /TypePrefix := "byte" | "shor" | "int" | "float" | "double" | "real" / "near" | "far" | "word" | "dword" | "qword" /AsmOffsetExpr := "offset" AsmExpr /AsmSegExpr := "seg" AsmExpr /SignExpr := ("+" | "-") AsmUnaryExpr /NotExpr := "!" AsmUnaryExpr /ComplementExpr := "~" AsmUnaryExpr /)

parseAsmPrimaryExpr
Expression parseAsmPrimaryExpr()

$(BNF AsmPrimaryExpr := / IntExpr | FloatExpr | DollarExpr | / AsmBracketExpr |AsmLocalSizeExpr | AsmRegisterExpr | / IdentifiersExpr /IntExpr := IntegerLiteral /FloatExpr := FloatLiteral /DollarExpr := "$" /AsmBracketExpr := "[" AsmExpr "]" /AsmLocalSizeExpr := "__LOCAL_SIZE" /AsmRegisterExpr := ...)

newBinaryExpr
Expression newBinaryExpr(Expression l, Expression r, Token* op)

Instantiates a function that returns a new binary expression.

NewBinaryExpr
alias NewBinaryExpr = Expression function(Expression, Expression, Token*)

The function signature of newBinaryExpr.

parseExpression
Expression parseExpression()

The root method for parsing an Expression. $(BNF Expression := CommaExpr /CommaExpr := AssignExpr ("," AssignExpr)*)

parseAssignExpr
Expression parseAssignExpr()

$(BNF AssignExpr := CondExpr (AssignOp AssignExpr)* /AssignOp := "=" | "<<=" | ">>=" | ">>>=" | "|=" | "&=" | / "+=" | "-=" | "/=" | "*=" | "%=" | "^=" | "~=" | "^^=")

parseCondExpr
Expression parseCondExpr()

$(BNF CondExpr := BinaryExpr ("?" Expression ":" CondExpr)?)

PREC
enum PREC

Enumeration of binary operator precedence values.

parseBinaryOp
PREC parseBinaryOp(out NewBinaryExpr fn, PREC prevPrec)

Consumes the tokens of a binary operator.

parseBinaryExpr
Expression parseBinaryExpr(PREC prevPrec = PREC.None)

Parses a binary operator expression.

parsePostExpr
Expression parsePostExpr()

$(BNF PostExpr := UnaryExpr / (PostIdExpr | IncOrDecExpr | CallExpr | SliceExpr | IndexExpr)* /PostIdExpr := "." (NewExpr | IdentifierExpr) /IncOrDecExpr := ("++" | "--") /CallExpr := "(" Arguments? ")" /RangeExpr := AssignExpr ".." AssignExpr /SliceExpr := "[" RangeExpr? "]") /IndexExpr := "[" ExpressionList "]")

parseUnaryExpr
Expression parseUnaryExpr()

$(BNF UnaryExpr := PrimaryExpr | / NewExpr | AddressExpr | PreIncrExpr | / PreDecrExpr | DerefExpr | SignExpr | / NotExpr | CompExpr | DeleteExpr | / CastExpr | TypeDotIdExpr /AddressExpr := "&" UnaryExpr /PreIncrExpr := "++" UnaryExpr /PreDecrExpr := "--" UnaryExpr /DerefExpr := "*" UnaryExpr /SignExpr := ("-" | "+") UnaryExpr /NotExpr := "!" UnaryExpr /CompExpr := "~" UnaryExpr /DeleteExpr := delete UnaryExpr /CastExpr := cast "(" Type? ")" UnaryExpr /TypeDotIdExpr := "(" Type ")" "." Identifier /TypeExpr := Modifier Type)

parseIdentifiersExpr
Expression parseIdentifiersExpr()

$(BNF IdentifiersExpr := / ModuleScopeExpr? IdentifierExpr ("." IdentifierExpr)* /ModuleScopeExpr := ".")

parseIdentifierExpr
Expression parseIdentifierExpr(Expression next = null)

$(BNF IdentifierExpr := Identifier | TemplateInstance /TemplateInstance := Identifier "!" TemplateArgumentsOneOrMore)

parseLambdaExprBody
Expression parseLambdaExprBody()

$(BNF LambdaBody := AssignExpr)

parseSingleParamLambdaExpr
Expression parseSingleParamLambdaExpr()

$(BNF LambdaExpr := LambdaParams "=>" LambdaBody /LambdaParams := Identifier | ParameterList ParamsPostfix)

parsePrimaryExpr
Expression parsePrimaryExpr()

$(BNF PrimaryExpr := IdentifierExpr | ModuleScopeExpr | / LambdaExpr | TypeofExpr | ThisExpr | SuperExpr | / NullExpr | BoolExpr | DollarExpr | IntExpr | FloatExpr | / CharExpr | StringExpr | ArrayLiteralExpr | AArrayLiteralExpr | / FuncLiteralExpr | AssertExpr | MixinExpr | ImportExpr | / TypeidExpr | IsExpr | ParenExpr | TraitsExpr | TypeDotIdExpr | / SpecialTokenExpr /TypeofExpr := TypeofType /ThisExpr := this /SuperExpr := super /NullExpr := null /BoolExpr := true | false /DollarExpr := "$" /IntExpr := IntegerLiteral /FloatExpr := FloatLiteral /CharExpr := CharacterLiteral /StringExpr := StringLiteral+ /StringLiteral := NormalStringLiteral | EscapeStringLiteral | / RawStringLiteral | HexStringLiteral | DelimitedStringLiteral | / TokenStringLiteral /ArrayLiteralExpr := "[" ExpressionList2 "]" /AArrayLiteralExpr := "[" KeyValue ("," KeyValue)* ","? "]" /KeyValue := (AssignExpr ":" AssignExpr) /FuncLiteralExpr := (function | delegate)? / (ReturnType? ParameterList FunctionPostfix?)? "{" Statements "}" /AssertExpr := assert "(" AssignExpr ("," AssignExpr)? ")" /MixinExpr := mixin "(" AssignExpr ")" /ImportExpr := import "(" AssignExpr ")" /TypeidExpr := typeid "(" Type ")" /IsExpr := is "(" Declarator (Specialization TemplateParameterList2)? ")" /Specialization := ((":" | "==") (SpecToken | Type)) /SpecToken := typedef | struct | union | class | interface | enum | / function | delegate | super | return | / const | immutable | inout | shared /ParenExpr := "(" Expression ")" /TraitsExpr := __traits "(" Identifier ("," TemplateArguments)? ")" /TypeDotIdExpr := "(" Type ")" "." Identifier /SpecialTokenExpr := SpecialToken)

parseNewExpr
Expression parseNewExpr(Expression frame = null)

$(BNF NewExpr := NewAnonClassExpr | NewObjectExpr /NewAnonClassExpr := / new NewArguments? class NewArguments? / (SuperClass InterfaceClasses)? ClassBody /NewObjectExpr := new NewArguments? Type (NewArguments | NewArray)? /NewArguments := "(" ArgumentList ")" /NewArray := "[" AssignExpr "]")

parseDeclaratorOptId
Type parseDeclaratorOptId(ref Token* ident)

Parses a Declarator with an optional Identifier.

parseDeclarator
Type parseDeclarator(ref Token* ident)

Parses a Declarator with an Identifier.

parseType
Type parseType()

Parses a full Type.

parseBasicTypes
Type parseBasicTypes()

Parses the basic types.

parseIdentifierType
Type parseIdentifierType(Type next = null)

$(BNF IdentifierType := Identifier | TemplateInstance)

parseTypeofType
Type parseTypeofType()

$(BNF TypeofType := typeof "(" Expression ")" | TypeofReturn /TypeofReturn := typeof "(" return ")")

parseQualifiedType
Type parseQualifiedType()

$(BNF QualifiedType := / (this | super | TypeofType | ModuleScopeType? IdentifierType) / ("." IdentifierType)*)

parseBasicType
Type parseBasicType()

$(BNF BasicType := IntegralType | QualifiedType | ModParenType /ModParenType := Modifier "(" Type ")")

parseBasicType2
Type parseBasicType2(Type t)

$(BNF BasicType2 := / (PointerType | ArrayType | FunctionType | DelegateType)* /PointerType := "*" /FunctionType := function ParameterList /DelegateType := delegate ParameterList)

parseDeclaratorSuffix
Type parseDeclaratorSuffix(Type lhsType)

Parses the array types after the declarator (C-style.) E.g.: int a[]

parseArrayType
Type parseArrayType(Type t)

$(BNF ArrayType := "[" (Type | ArrayTypeIndex) "]" /ArrayTypeIndex := AssignExpr (".." AssignExpr)?)

parseExpressionList
Expression[] parseExpressionList()

Parses a list of AssignExpressions. $(BNF ExpressionList := AssignExpr ("," AssignExpr)*)

parseExpressionList2
Expression[] parseExpressionList2(TOK closing_tok)

Parses an optional ExpressionList and allows a trailing comma. $(BNF ExpressionList2 := (ExpressionList ","?)? )

parseArguments
Expression[] parseArguments()

Parses a list of Arguments. $(BNF Arguments := "(" ExpressionList2 ")")

parseParameterList
Parameters parseParameterList()

Parses a ParameterList. $(BNF ParameterList := "(" Parameters? ")" /Parameters := Parameter ("," Parameter)* ","? /Parameter := StorageClasses? (Type Name? | Type? Name ) / ("=" AssignExpr)?)

parseOneOrMoreTemplateArguments
TemplateArguments parseOneOrMoreTemplateArguments()

$(BNF TemplateArgumentsOneOrMore := / TemplateArgumentList | TemplateArgumentSingle)

parseTemplateArguments
TemplateArguments parseTemplateArguments()

$(BNF TemplateArgumentList := "(" TemplateArguments? ")")

parseTemplateArguments2
TemplateArguments parseTemplateArguments2()

$(BNF TemplateArgumentList2 := TemplateArguments (?= "$(RP)"))

parseTypeArgument
Type parseTypeArgument()

Used with method tryToParse(). $(BNF TypeArgument := Type (?= "," | "$(RP)"))

parseTemplateArguments_
TemplateArguments parseTemplateArguments_()

$(BNF TemplateArguments := TemplateArgument ("," TemplateArgument)* /TemplateArgument := TypeArgument | AssignExpr)

parseOptionalConstraint
Expression parseOptionalConstraint()

$(BNF Constraint := if "(" ConstraintExpr ")")

parseTemplateParameterList
TemplateParameters parseTemplateParameterList()

$(BNF TemplateParameterList := "(" TemplateParameters? ")")

parseTemplateParameterList2
TemplateParameters parseTemplateParameterList2()

$(BNF TemplateParameterList2 := "," TemplateParameters "$(RP)")

parseTemplateParameterList_
void parseTemplateParameterList_(TemplateParameters tparams)

Parses template parameters. $(BNF TemplateParameters := TemplateParam ("," TemplateParam)* /TemplateParam := / TemplateAliasParam | TemplateTypeParam | TemplateTupleParam | / TemplateValueParam | TemplateThisParam /TemplateAliasParam := alias Identifier SpecOrDefaultType /TemplateTypeParam := Identifier SpecOrDefaultType /TemplateTupleParam := Identifier "..." /TemplateValueParam := Declarator SpecOrDefaultValue /TemplateThisParam := this Identifier SpecOrDefaultType # D2.0 /SpecOrDefaultType := (":" Type)? ("=" Type)? /SpecOrDefaultValue := (":" Value)? ("=" Value)? /Value := CondExpr /)

getPrintable
cstring getPrintable(Token* token)

Returns the string of a token printable to the client.

require
void require()

Requires a token of kind T!str.

require2
void require2()

Requires a token of kind tok. Uses the token end as the error location.

optionalIdentifier
Token* optionalIdentifier()

Parses an optional identifier.

requireIdentifier
Token* requireIdentifier(MID mid)

Reports an error if the current token is not an identifier.

requireOpening
Token* requireOpening()

Returns the opening bracket or the current token.

requireClosing
void requireClosing(Token* opening)

Reports an error if the closing counterpart of a token is not found.

hasInvalidUTF8
bool hasInvalidUTF8(cbinstr str, Token* begin)

Returns true if the string str has an invalid UTF-8 sequence.

error
void error(Token* token, MID mid, ...)
void error(MID mid, ...)
error_eL
void error_eL(MID mid, ...)
error2
void error2(MID mid, Token* token)
void error2(MID mid, string arg, Token* token)
error2_eL
void error2_eL(MID mid, string arg, Token* token)

Forwards error parameters.

error
void error(TypeInfo[] _arguments, va_list _argptr, Token* token, bool endLoc, cstring formatMsg)
void error(TypeInfo[] _arguments, va_list _argptr, Token* token, bool endLoc, MID mid)

Creates an error report and appends it to a list.

Meta