Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
dmd.parse
Takes a token stream from the lexer, and parses it into an abstract syntax tree.
Specification D Grammar
Authors:
License:
Source parse.d
Documentation https://dlang.org/phobos/dmd_parse.html
- class
Parser
(AST, Lexer = dmd.lexer.Lexer): Lexer; -
- bool
transitionIn
; - -transition=in is active, in parameters are listed
- scope this(const ref Loc
loc
, AST.Module_module
, const(char)[]input
, booldoDocComment
, ErrorSinkerrorSink
, const CompileEnv*compileEnv
, const booldoUnittests
); - Use this constructor for string mixins.
Input loc = location in source file of mixin
- scope this(AST.Module
_module
, const(char)[]input
, booldoDocComment
, ErrorSinkerrorSink
, const CompileEnv*compileEnv
, const booldoUnittests
); - Main Parser constructor.
- AST.Dsymbols*
parseModule
(); - Parse a module, i.e. the optional module x.y.z declaration and all declarations found in the current file.Returns:the list of declarations or an empty list in case of malformed declarations, the module declaration will be stored as this.md if found
- final bool
parseModuleDeclaration
(); - Parse the optional module declarationReturns:false if a malformed module declaration was found
- final AST.Dsymbols*
parseModuleContent
(); - Parse the content of a module, i.e. all declarations found until the end of file.Returns:the list of declarations or an empty list in case of malformed declarations
- AST.Dsymbols*
parseDeclDefs
(intonce
, AST.Dsymbol*pLastDecl
= null, PrefixAttributes!AST*pAttrs
= null); - Parse declarations and definitionsParameters:
int once
!=0 means parse exactly one decl or def AST.Dsymbol* pLastDecl
set to last decl or def parsed PrefixAttributes!AST* pAttrs
keep track of attributes Returns:array of declared symbols - RootObject
parseTypeOrAssignExp
(TOKendtoken
= TOK.reserved); - Parse a Type or an ExpressionReturns:RootObject representing the AST
- AST.Parameter
parseAssignCondition
(); - Parse an assignment condition for if or while statements.Returns:The variable that is declared inside the condition
- 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.Statement
parseAsm
(boolendOfLine
); - Parse inline assembler block. Enters with token on the asm. https://dlang.org/spec/iasm.html
AsmStatement asm FunctionAttributes(opt) { AsmInstructionListopt }
AsmInstructionList AsmInstruction ; AsmInstruction ; AsmInstruction
Parameters:bool endOfLine
true if EOL means end of asm statement Returns:inline assembler block as a Statement - void
check
(Locloc
, TOKvalue
); - Issue error if the current token is not
value
, advance to next token.Parameters:Loc loc
location for error message TOK value
token value to compare with - void
check
(TOKvalue
); - Issue error if the current token is not
value
, advance to next token.Parameters:TOK value
token value to compare with - void
check
(TOKvalue
, const(char)*string
); - Issue error if the current token is not
value
, advance to next token.Parameters:TOK value
token value to compare with const(char)* string
for error message - enum
NeedDeclaratorId
; - bool
skipParens
(Token*t
, Token**pt
); - Skip parentheses.Parameters:
Token* t
on opening ( Token** pt
*pt is set to token past ')' on true Returns:true successful false some parsing error - AST.Expression
parsePrimaryExp
(); - Expression Parser
- static StorageClass
isBuiltinAtAttribute
(Identifierident
); - Recognize builtin @ attributesParameters:
Identifier ident
identifier Returns:storage class for attribute, 0 if not
- immutable PREC[EXP.max + 1]
precedence
; - Set operator precedence for each operator.Used by hdrgen
- struct
ParsedLinkage
(AST); - The result of the ParseLinkage function
- LINK
link
; - What linkage was specified
- CPPMANGLE
cppmangle
; - If extern(C++, class|struct), contains the class|struct
- AST.Identifiers*
idents
; - If extern(C++, some.identifier), will be the identifiers
- AST.Expressions*
identExps
; - If `extern(C++, (some_tuple_expression)|"string"), will be the expressions
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on Wed Dec 18 08:51:49 2024