# dmd.parse

Takes a token stream from the lexer, and parses it into an abstract syntax tree.

Specification: D Grammar

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: parse.d

Documentation: https://dlang.org/phobos/dmd_parse.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/parse.d

- `precedence`

  #### Declaration

  `immutable PREC[TOK.max + 1] `precedence`;`

  Set operator `precedence` for each operator.

  #### Discussion

  Used by hdrgen

- `Parser`

  #### Declaration

  `class `Parser`(AST): Lexer;`

  - `this`

    #### Declaration

    `this(ref const Loc `loc`, AST.Module `_module`, const(char)[] `input`, bool `doDocComment`);`

    Use this constructor for string mixins.

    Input: `loc` location in source file of mixin

  - `parseTypeOrAssignExp`

    #### Declaration

    `RootObject `parseTypeOrAssignExp`(TOK `endtoken` = TOK.reserved);`

    Parse a Type or an Expression

    #### Return Value

    RootObject representing the AST

  - `parseAssignCondition`

    #### Declaration

    `AST.Parameter `parseAssignCondition`();`

    Parse an assignment condition for if or while statements.

    #### Return Value

    The variable that is declared inside the condition

  - `parseStatement`

    #### Declaration

    `AST.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 last token of statement

  - `parsePrimaryExp`

    #### Declaration

    `AST.Expression `parsePrimaryExp`();`

    Expression Parser

  - `isBuiltinAtAttribute`

    #### Declaration

    `static StorageClass `isBuiltinAtAttribute`(Identifier `ident`);`

    Recognize builtin @ attributes

    #### Parameters

    `Identifier `ident`` | identifier

    #### Return Value

    storage class for attribute, 0 if not