Parser

final
class Parser : Lexer {}

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

this
this(Module _module, const(char)[] input, bool doDocComment)
Undocumented in source.

Members

Enums

NeedDeclaratorId
enum NeedDeclaratorId
Undocumented in source.

Functions

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

Give error on redundant/conflicting storage class.

check
void check(Loc loc, TOK value)
Undocumented in source. Be warned that the author may not have intended to support it.
check
void check(TOK value)
Undocumented in source. Be warned that the author may not have intended to support it.
check
void check(TOK value, const(char)* string)
Undocumented in source. Be warned that the author may not have intended to support it.
checkCstyleTypeSyntax
void checkCstyleTypeSyntax(Loc loc, Type t, int alt, Identifier ident)
Undocumented in source. Be warned that the author may not have intended to support it.
checkDanglingElse
void checkDanglingElse(Loc elseloc)
checkParens
void checkParens(TOK value, Expression e)
Undocumented in source. Be warned that the author may not have intended to support it.
isBasicType
bool isBasicType(Token** pt)
Undocumented in source. Be warned that the author may not have intended to support it.
isDeclaration
bool isDeclaration(Token* t, NeedDeclaratorId needId, TOK endtok, Token** pt)

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

isDeclarator
bool isDeclarator(Token** pt, int* haveId, int* haveTpl, TOK endtok, bool allowAltSyntax)
Undocumented in source. Be warned that the author may not have intended to support it.
isExpression
bool isExpression(Token** pt)
Undocumented in source. Be warned that the author may not have intended to support it.
isParameters
bool isParameters(Token** pt)
Undocumented in source. Be warned that the author may not have intended to support it.
parseAddExp
Expression parseAddExp()
Undocumented in source. Be warned that the author may not have intended to support it.
parseAggregate
Dsymbol parseAggregate()

Parse struct, union, interface, class.

parseAndAndExp
Expression parseAndAndExp()
Undocumented in source. Be warned that the author may not have intended to support it.
parseAndExp
Expression parseAndExp()
Undocumented in source. Be warned that the author may not have intended to support it.
parseArguments
Expressions* parseArguments()

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

parseAssignExp
Expression parseAssignExp()
Undocumented in source. Be warned that the author may not have intended to support it.
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()
parseBasicType
Type parseBasicType(bool dontLookDotIdents)
Undocumented in source. Be warned that the author may not have intended to support it.
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

parseBasicTypeStartingAt
Type parseBasicTypeStartingAt(TypeQualified tid, bool dontLookDotIdents)
Undocumented in source. Be warned that the author may not have intended to support it.
parseBlock
Dsymbols* parseBlock(Dsymbol* pLastDecl, PrefixAttributes* pAttrs)

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

parseCmpExp
Expression parseCmpExp()
Undocumented in source. Be warned that the author may not have intended to support it.
parseCondExp
Expression parseCondExp()
Undocumented in source. Be warned that the author may not have intended to support it.
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

parseDeclDefs
Dsymbols* parseDeclDefs(int once, Dsymbol* pLastDecl, PrefixAttributes* pAttrs)
Undocumented in source. Be warned that the author may not have intended to support it.
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.

parseDeclarator
Type parseDeclarator(Type t, int* palt, Identifier* pident, TemplateParameters** tpl, StorageClass storageClass, int* pdisable, Expressions** pudas)
Undocumented in source. Be warned that the author may not have intended to support it.
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()
parseExpression
Expression parseExpression()
Undocumented in source. Be warned that the author may not have intended to support it.
parseFunctionLiteral
Dsymbol parseFunctionLiteral()
Undocumented in source. Be warned that the author may not have intended to support it.
parseImport
Dsymbols* parseImport()
Undocumented in source. Be warned that the author may not have intended to support it.
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, 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);

parseModule
Dsymbols* parseModule()
Undocumented in source. Be warned that the author may not have intended to support it.
parseMulExp
Expression parseMulExp()
Undocumented in source. Be warned that the author may not have intended to support it.
parseNew
Dsymbol parseNew(PrefixAttributes* pAttrs)

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

parseNewExp
Expression parseNewExp(Expression thisexp)
parseOrExp
Expression parseOrExp()
Undocumented in source. Be warned that the author may not have intended to support it.
parseOrOrExp
Expression parseOrOrExp()
Undocumented in source. Be warned that the author may not have intended to support it.
parseParameters
Parameters* parseParameters(int* pvarargs, TemplateParameters** tpl)

Parse parameter list.

parsePostExp
Expression parsePostExp(Expression e)
Undocumented in source. Be warned that the author may not have intended to support it.
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'.

parseShiftExp
Expression parseShiftExp()
Undocumented in source. Be warned that the author may not have intended to support it.
parseStatement
Statement parseStatement(int flags, const(char)** endPtr, Loc* pEndloc)

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'.

parseStorageClasses
void parseStorageClasses(StorageClass storage_class, LINK link, bool setAlignment, Expression ealign, Expressions* udas)
Undocumented in source. Be warned that the author may not have intended to support it.
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)

Parse a TemplateDeclaration.

parseTemplateParameterList
TemplateParameters* parseTemplateParameterList(int flag)

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

parseType
Type parseType(Identifier* pident, TemplateParameters** ptpl)
Undocumented in source. Be warned that the author may not have intended to support it.
parseTypeCtor
StorageClass parseTypeCtor()
Undocumented in source. Be warned that the author may not have intended to support it.
parseTypeof
TypeQualified parseTypeof()

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

parseUnaryExp
Expression parseUnaryExp()
Undocumented in source. Be warned that the author may not have intended to support it.
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

parseXorExp
Expression parseXorExp()
Undocumented in source. Be warned that the author may not have intended to support it.
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

skipParensIf
bool skipParensIf(Token* t, Token** pt)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

cppmangle
CPPMANGLE cppmangle;
Undocumented in source.
endloc
Loc endloc;
Undocumented in source.
inBrackets
int inBrackets;
Undocumented in source.
linkage
LINK linkage;
Undocumented in source.
lookingForElse
Loc lookingForElse;
Undocumented in source.
md
ModuleDeclaration* md;
Undocumented in source.
mod
Module mod;
Undocumented in source.

Inherited Members

From Lexer

stringbuffer
OutBuffer stringbuffer;
Undocumented in source.
scanloc
Loc scanloc;
Undocumented in source.
base
const(char)* base;
Undocumented in source.
end
const(char)* end;
Undocumented in source.
p
const(char)* p;
Undocumented in source.
line
const(char)* line;
Undocumented in source.
token
Token token;
Undocumented in source.
doDocComment
bool doDocComment;
Undocumented in source.
anyToken
bool anyToken;
Undocumented in source.
commentToken
bool commentToken;
Undocumented in source.
errors
bool errors;
Undocumented in source.
nextToken
TOK nextToken()
Undocumented in source. Be warned that the author may not have intended to support it.
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.

peek
Token* peek(Token* ct)
Undocumented in source. Be warned that the author may not have intended to support it.
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.

loc
Loc loc()
Undocumented in source. Be warned that the author may not have intended to support it.
error
void error(const(char)* format, ...)
Undocumented in source. Be warned that the author may not have intended to support it.
error
void error(Loc loc, const(char)* format, ...)
Undocumented in source. Be warned that the author may not have intended to support it.
deprecation
void deprecation(const(char)* format, ...)
Undocumented in source. Be warned that the author may not have intended to support it.
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