Parse-statement
Parse a statement.
- Signature
(parse-statement pstate) → (mv erp stmt span new-pstate)
- Arguments
- pstate — Guard (parstatep pstate).
- Returns
- stmt — Type (stmtp stmt).
- span — Type (spanp span).
- new-pstate — Type (parstatep new-pstate).
Most statements start with distinct keywords or punctuators
(one punctuator, the open curly brace),
but both labeled statements and expression statements
may start with an identifier.
However, for a labeled statement,
the token after the identifier is a colon,
which cannot be an expression.
So we are able to distinguish all kinds of statements
based on the first one or two tokens.
The well-known dangling-else grammatical ambiguity is dealt with
by associating the else with the closest if,
as required in [C:6.8.4/3].
There is a syntactic overlap between the two kinds of for loops,
the one with an expression and the one with a declaration.
An identifier may be a declaration specifier
or (the start of) an expression.
For now we handle the situation approximately:
if the token there may start an expresison,
we commit to parsing an expression;
otherwise we parse a declaration.
In other words, we may fail to accept the case of
a declaration that starts with a typedef name for now.
We plan to rectify this situation soon.