Parse-primary-expression
Parse a primary-expression.
- Signature
(parse-primary-expression token input)
→
(mv tree next-token rest-input)
- Arguments
- token — Guard (abnf::tree-optionp token).
- input — Guard (abnf::tree-listp input).
- Returns
- tree — Type (abnf::tree-resultp tree).
- next-token — Type (abnf::tree-optionp next-token).
- rest-input — Type (abnf::tree-listp rest-input).
A primary expression can start with the keyword "(",
in which case it can be either a unit expression,
a parenthesized expression or an affine group literal.
Since the unit expression is most restricted, it is tried first.
The group literal is more restricted than a parenthesized expression,
and ends with ")group", so we try to parse literals before
trying parenthesized expressions.
There are quite a few kinds of primary expressions that can start with
an identifier. A variable reference is just a plain identifier.
Free function calls start with an identifier but are followed by
function-arguments, so they must be tried before variable
references.
Associated constants and static function calls start with a
named type, which can be a primitive type or an identifier, which is
then followed by "::".
Static function calls start with the same syntax as associated constants
but are followed by function arguments, so they must be tried before
assocated constants.