Parse-primary-expression
Parse a primary expression.
- Signature
(parse-primary-expression pstate)
→
(mv erp expr span new-pstate)
- Arguments
- pstate — Guard (parstatep pstate).
- Returns
- expr — Type (exprp expr).
- span — Type (spanp span).
- new-pstate — Type (parstatep new-pstate).
This is called when we expect an expression.
We read a token.
If the token is an identifier or a constant or a string literal,
that is the whole expression.
If the token is an open parenthesis,
we parse an expression and a closed parenthesis:
we have a parenthesized expression.
If the token is the keyword _Generic,
we parse an open parenthesis and an assignment expression,
then a comma and a generic association,
since there must be at least one.
Then we call a separate function to parse
zero or more additional generic associations.
Finally we parse a closed parenthesis and return a generic selection.
If the token is none of the above,
including the token being absent,
it is an error.