Parse-primary-expression
Parse a primary expression.
- Signature
(parse-primary-expression parstate)
→
(mv erp expr span new-parstate)
- Arguments
- parstate — Guard (parstatep parstate).
- Returns
- expr — Type (exprp expr).
- span — Type (spanp span).
- new-parstate — Type (parstatep new-parstate), given (parstatep parstate).
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.