dmd.parse
Source parse.d
Documentation https://dlang.org/phobos/dmd_parse.html
- PREC[TOK.max_]
precedence
; - Set operator precedence for each operator.
- class
Parser
(AST): Lexer; -
- this(Loc
loc
, AST.Module_module
, const(char)[]input
, booldoDocComment
); - Use this constructor for string mixins.
Input loc location in source file of mixin
- AST.Dsymbols*
parseAutoDeclarations
(StorageClassstorageClass
, 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 ';'
- AST.Dsymbols*
parseBlock
(AST.Dsymbol*pLastDecl
, PrefixAttributes!AST*pAttrs
= null); - Parse declarations after an align, protection, or extern decl.
- StorageClass
appendStorageClass
(StorageClassstorageClass
, StorageClassstc
, booldeprec
= false); - Give error on redundant/conflicting storage class.
TODO remove deprecation in 2.068 and keep only error
- StorageClass
parseAttribute
(AST.Expressions**pudas
); - Parse attribute, lexer is on '@'.
Input pudas array of UDAs to append to
Returns:storage class if a predefined attribute; also scanner remains on identifier. 0 if not a predefined attribute *pudas set if user defined attribute, scanner is past UDA *pudas NULL if not a user defined attribute - StorageClass
parsePostfix
(StorageClassstorageClass
, AST.Expressions**pudas
); - Parse const/immutable/shared/inout/nothrow/pure postfix
- AST.Expression
parseConstraint
(); - Parse constraint. Constraint is of the form: if ( ConstraintExpression )
- AST.TemplateDeclaration
parseTemplateDeclaration
(boolismixin
= false); - Parse a TemplateDeclaration.
- AST.TemplateParameters*
parseTemplateParameterList
(intflag
= 0); - Parse template parameter list.
Input flag 0: parsing "( list )" 1: parsing non-empty "list )"
- AST.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);
- AST.Objects*
parseTemplateArguments
(); - Parse template arguments.
Input current token is opening '!'
Output current token is one after closing ')'
- AST.Objects*
parseTemplateArgumentList
(); - Parse template argument list.
Input current token is opening '(', or ',' for _traits
Output current token is one after closing ')'
- AST.Objects*
parseTemplateSingleArgument
(); - Parse single template argument, to support the syntax: foo!arg
Input current token is the arg
- AST.StaticAssert
parseStaticAssert
(); - Parse a static assertion. Current token is 'static'.
- AST.TypeQualified
parseTypeof
(); - Parse typeof(expression). Current token is on the 'typeof'.
- AST.Type
parseVector
(); - Parse _vector(type). Current token is on the '_vector'.
- LINK
parseLinkage
(AST.Identifiers**pidents
, out CPPMANGLEcppmangle
); Parse extern (linkage) extern (C++, namespaces) The parser is on the 'extern' token.
- AST.Identifiers*
parseQualifiedIdentifier
(const(char)*entity
); - Parse ident1.ident2.ident3Parameters:
const(char)* entity
what qualified identifier is expected to resolve into. Used only for better error message Returns:array of identifiers with actual qualified one stored last - AST.Condition
parseDebugCondition
(); - Parse a debug conditional
- AST.Condition
parseVersionCondition
(); - Parse a version conditional
- AST.Condition
parseStaticIfCondition
(); - static if (expression) body else body Current token is 'static'.
- AST.Dsymbol
parseCtor
(PrefixAttributes!AST*pAttrs
); - Parse a constructor definition: this(parameters) { body } or postblit: this(this) { body } or constructor template: this(templateparameters)(parameters) { body } Current token is 'this'.
- AST.Dsymbol
parseDtor
(PrefixAttributes!AST*pAttrs
); - Parse a destructor definition: ~this() { body } Current token is '~'.
- AST.Dsymbol
parseStaticCtor
(PrefixAttributes!AST*pAttrs
); - Parse a static constructor definition: static this() { body } Current token is 'static'.
- AST.Dsymbol
parseStaticDtor
(PrefixAttributes!AST*pAttrs
); - Parse a static destructor definition: static ~this() { body } Current token is 'static'.
- AST.Dsymbol
parseSharedStaticCtor
(PrefixAttributes!AST*pAttrs
); - Parse a shared static constructor definition: shared static this() { body } Current token is 'shared'.
- AST.Dsymbol
parseSharedStaticDtor
(PrefixAttributes!AST*pAttrs
); - Parse a shared static destructor definition: shared static ~this() { body } Current token is 'shared'.
- AST.Dsymbol
parseInvariant
(PrefixAttributes!AST*pAttrs
); - Parse an invariant definition: invariant() { body } Current token is 'invariant'.
- AST.Dsymbol
parseUnitTest
(PrefixAttributes!AST*pAttrs
); - Parse a unittest definition: unittest { body } Current token is 'unittest'.
- AST.Dsymbol
parseNew
(PrefixAttributes!AST*pAttrs
); - Parse a new definition: new(parameters) { body } Current token is 'new'.
- AST.Dsymbol
parseDelete
(PrefixAttributes!AST*pAttrs
); - Parse a delete definition: delete(parameters) { body } Current token is 'delete'.
- AST.Parameters*
parseParameters
(int*pvarargs
, AST.TemplateParameters**tpl
= null); - Parse parameter list.
- AST.EnumDeclaration
parseEnum
(); - AST.Dsymbol
parseAggregate
(); - Parse struct, union, interface, class.
- AST.BaseClasses*
parseBaseClasses
(); - AST.Type
parseBasicType2
(AST.Typet
); - Parse things that follow the initial type t. t * t [] t [type] t [expression] t [expression .. expression] t function t delegate
- AST.Dsymbols*
parseDeclarations
(boolautodecl
, PrefixAttributes!AST*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.
- AST.FuncDeclaration
parseContracts
(AST.FuncDeclarationf
); - Parse contracts following function declaration.
- void
checkDanglingElse
(Locelseloc
); - ParseForeachRet!(isStatic, isDecl)
parseForeach
(bool isStatic, bool isDecl)(Locloc
, ParseForeachArgs!(isStatic, isDecl)args
); - Parses foreach statements, static foreach statements and static foreach declarations. The template parameter isStatic is true, iff a static foreach should be parsed. If isStatic is true, isDecl can be true to indicate that a static foreach declaration should be parsed.
- AST.Statement
parseStatement
(intflags
, const(char)**endPtr
= null, Loc*pEndloc
= null); Input flags PSxxxx
Output pEndloc if { ... statements ... }, store location of closing brace, otherwise loc of last token of statement
- AST.Initializer
parseInitializer
(); - Parse initializer for variable declaration.
- AST.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__.
- enum
NeedDeclaratorId
; - bool
isDeclaration
(Token*t
, NeedDeclaratorIdneedId
, TOKendtok
, Token**pt
); - Determine if the scanner is sitting on the start of a declaration.Parameters:
Token* t
current token of the scanner NeedDeclaratorId needId
flag with additional requirements for a declaration TOK endtok
ending token Token** pt
will be set ending token (if not null) Output true if the token
t
is a declaration, false otherwise - 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
Returns:true successful false some parsing error - 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
Returns:true successful false some parsing error - AST.Expression
parsePrimaryExp
(); - Expression Parser
- AST.Expressions*
parseArguments
(); - Collect argument list. Assume current token is ',', '(' or '['.
- AST.Expression
parseNewExp
(AST.Expressionthisexp
); - void
addComment
(AST.Dsymbols
, const(char)*blockComment
);