Parser

final
class Parser : Lexer {
Module mod;
ModuleDeclaration* md;
LINK linkage;
CPPMANGLE cppmangle;
Loc endloc;
int inBrackets;
Loc lookingForElse;
}

Constructors

this
this(Loc loc, Module _module, const(char)[] input, bool doDocComment)

Use this constructor for string mixins. Input: loc location in source file of mixin

Members

Functions

addComment
void addComment(Dsymbol s, const(char)* blockComment)
appendStorageClass
StorageClass appendStorageClass(StorageClass storageClass, StorageClass stc, bool deprec = false)

Give error on redundant/conflicting storage class.

checkDanglingElse
void checkDanglingElse(Loc elseloc)
isDeclaration
bool isDeclaration(Token* t, NeedDeclaratorId needId, TOK endtok, Token** pt)

Determine if the scanner is sitting on the start of a declaration.

parseAggregate
Dsymbol parseAggregate()

Parse struct, union, interface, class.

parseArguments
Expressions* parseArguments()

Collect argument list. Assume current token is ',', '(' or '['.

parseAttribute
StorageClass parseAttribute(Expressions** pudas)

Parse attribute, lexer is on '@'. Input: pudas array of UDAs to append to

parseAutoDeclarations
Dsymbols* parseAutoDeclarations(StorageClass storageClass, const(char)* comment)

Parse auto declarations of the form: storageClass ident = init, ident = init, ... ; and return the array of them. Starts with token on the first ident. Ends with scanner past closing ';'

parseBaseClasses
BaseClasses* parseBaseClasses()
parseBasicType2
Type parseBasicType2(Type t)

Parse things that follow the initial type t. t * t [] t type t expression t [expression .. expression] t function t delegate

parseBlock
Dsymbols* parseBlock(Dsymbol* pLastDecl, PrefixAttributes* pAttrs = null)

Parse declarations after an align, protection, or extern decl.

parseConstraint
Expression parseConstraint()

Parse constraint. Constraint is of the form: if ( ConstraintExpression )

parseContracts
FuncDeclaration parseContracts(FuncDeclaration f)

Parse contracts following function declaration.

parseCtor
Dsymbol parseCtor(PrefixAttributes* pAttrs)

Parse a constructor definition: this(parameters) { body } or postblit: this(this) { body } or constructor template: this(templateparameters)(parameters) { body } Current token is 'this'.

parseDebugCondition
Condition parseDebugCondition()

Parse a debug conditional

parseDeclarations
Dsymbols* parseDeclarations(bool autodecl, PrefixAttributes* pAttrs, const(char)* comment)

Parse Declarations. These can be: 1. declarations at global/class level 2. declarations at statement level Return array of Declaration *'s.

parseDefaultInitExp
Expression parseDefaultInitExp()

Parses default argument initializer expression that is an assign expression, with special handling for __FILE__, __FILE_DIR__, __LINE__, __MODULE__, __FUNCTION__, and __PRETTY_FUNCTION__.

parseDelete
Dsymbol parseDelete(PrefixAttributes* pAttrs)

Parse a delete definition: delete(parameters) { body } Current token is 'delete'.

parseDtor
Dsymbol parseDtor(PrefixAttributes* pAttrs)

Parse a destructor definition: ~this() { body } Current token is '~'.

parseEnum
EnumDeclaration parseEnum()
parseInitializer
Initializer parseInitializer()

Parse initializer for variable declaration.

parseInvariant
Dsymbol parseInvariant(PrefixAttributes* pAttrs)

Parse an invariant definition: invariant() { body } Current token is 'invariant'.

parseLinkage
LINK parseLinkage(Identifiers** pidents, out CPPMANGLE cppmangle)

Parse: extern (linkage) extern (C++, namespaces) The parser is on the 'extern' token.

parseMixin
Dsymbol parseMixin()

Parse template mixin. mixin Foo; mixin Foo!(args); mixin a.b.c!(args).Foo!(args); mixin Foo!(args) identifier; mixin typeof(expr).identifier!(args);

parseNew
Dsymbol parseNew(PrefixAttributes* pAttrs)

Parse a new definition: new(parameters) { body } Current token is 'new'.

parseNewExp
Expression parseNewExp(Expression thisexp)
parseParameters
Parameters* parseParameters(int* pvarargs, TemplateParameters** tpl = null)

Parse parameter list.

parsePostfix
StorageClass parsePostfix(StorageClass storageClass, Expressions** pudas)

Parse const/immutable/shared/inout/nothrow/pure postfix

parsePrimaryExp
Expression parsePrimaryExp()

Expression Parser

parseQualifiedIdentifier
Identifiers* parseQualifiedIdentifier(const(char)* entity)

Parse ident1.ident2.ident3

parseSharedStaticCtor
Dsymbol parseSharedStaticCtor(PrefixAttributes* pAttrs)

Parse a shared static constructor definition: shared static this() { body } Current token is 'shared'.

parseSharedStaticDtor
Dsymbol parseSharedStaticDtor(PrefixAttributes* pAttrs)

Parse a shared static destructor definition: shared static ~this() { body } Current token is 'shared'.

parseStatement
Statement parseStatement(int flags, const(char)** endPtr = null, Loc* pEndloc = null)

Input: flags PSxxxx Output: pEndloc if { ... statements ... }, store location of closing brace, otherwise loc of first token of next statement

parseStaticAssert
StaticAssert parseStaticAssert()

Parse a static assertion. Current token is 'static'.

parseStaticCtor
Dsymbol parseStaticCtor(PrefixAttributes* pAttrs)

Parse a static constructor definition: static this() { body } Current token is 'static'.

parseStaticDtor
Dsymbol parseStaticDtor(PrefixAttributes* pAttrs)

Parse a static destructor definition: static ~this() { body } Current token is 'static'.

parseStaticIfCondition
Condition parseStaticIfCondition()

static if (expression) body else body Current token is 'static'.

parseTemplateArgumentList
Objects* parseTemplateArgumentList()

Parse template argument list. Input: current token is opening '(', or ',' for __traits Output: current token is one after closing ')'

parseTemplateArguments
Objects* parseTemplateArguments()

Parse template arguments. Input: current token is opening '!' Output: current token is one after closing ')'

parseTemplateDeclaration
TemplateDeclaration parseTemplateDeclaration(bool ismixin = false)

Parse a TemplateDeclaration.

parseTemplateParameterList
TemplateParameters* parseTemplateParameterList(int flag = 0)

Parse template parameter list. Input: flag 0: parsing "( list )" 1: parsing non-empty "list )"

parseTemplateSingleArgument
Objects* parseTemplateSingleArgument()

Parse single template argument, to support the syntax: foo!arg Input: current token is the arg

parseTypeof
TypeQualified parseTypeof()

Parse typeof(expression). Current token is on the 'typeof'.

parseUnitTest
Dsymbol parseUnitTest(PrefixAttributes* pAttrs)

Parse a unittest definition: unittest { body } Current token is 'unittest'.

parseVector
Type parseVector()

Parse __vector(type). Current token is on the '__vector'.

parseVersionCondition
Condition parseVersionCondition()

Parse a version conditional

skipAttributes
bool skipAttributes(Token* t, Token** pt)

Skip attributes. Input: t is on a candidate attribute Output: *pt is set to first non-attribute token on success

skipParens
bool skipParens(Token* t, Token** pt)

Skip parens, brackets. Input: t is on opening ( Output: *pt is set to closing token, which is ')' on success

Inherited Members

From Lexer

peekNext
TOK peekNext()

Look ahead at next token's value.

peekNext2
TOK peekNext2()

Look 2 tokens ahead at value.

scan
void scan(Token* t)

Turn next token in buffer into a token.

peekPastParen
Token* peekPastParen(Token* tk)

tk is on the opening (. Look ahead and return token that is past the closing ).

escapeSequence
uint escapeSequence()

Parse escape sequence.

wysiwygStringConstant
TOK wysiwygStringConstant(Token* t, int tc)
hexStringConstant
TOK hexStringConstant(Token* t)

Lex hex strings: x"0A ae 34FE BD"

delimitedStringConstant
TOK delimitedStringConstant(Token* t)

Lex delimited strings: q"(foo(xxx))" // "foo(xxx)" q"[foo(]" // "foo(" q"/foo]/" // "foo]" q"HERE foo HERE" // "foo\n" Input: p is on the "

tokenStringConstant
TOK tokenStringConstant(Token* t)

Lex delimited strings: q{ foo(xxx) } // " foo(xxx) " q{foo(} // "foo(" q{{foo}"}"} // "{foo}"}"" Input: p is on the q

escapeStringConstant
TOK escapeStringConstant(Token* t, int wide)
charConstant
TOK charConstant(Token* t)
stringPostfix
void stringPostfix(Token* t)

Get postfix of string literal.

number
TOK number(Token* t)

Read in a number. If it's an integer, store it in tok.TKutok.Vlong. integers can be decimal, octal or hex Handle the suffixes U, UL, LU, L, etc. If it's double, store it in tok.TKutok.Vdouble.

inreal
TOK inreal(Token* t)

Read in characters, converting them to real.

poundLine
void poundLine()

parse: #line linnum filespec also allow __LINE__ for linnum, and __FILE__ for filespec

decodeUTF
uint decodeUTF()

Decode UTF character. Issue error messages for invalid sequences. Return decoded character, advance p to last character in UTF sequence.

getDocComment
void getDocComment(Token* t, uint lineComment)

Parse doc comment embedded between t->ptr and p. Remove trailing blanks and tabs from lines. Replace all newlines with \n. Remove leading comment character from each line. Decide if it's a lineComment or a blockComment. Append to previous one for this token.

combineComments
const(char)* combineComments(const(char)* c1, const(char)* c2)

Combine two document comments into one, separated by a newline.

Meta