Parse-specifier/qualifier
Parse a specifier or qualifier.
- Signature
(parse-specifier/qualifier tyspec-seenp parstate)
→
(mv erp specqual span new-parstate)
- Arguments
- tyspec-seenp — Guard (booleanp tyspec-seenp).
- parstate — Guard (parstatep parstate).
- Returns
- specqual — Type (spec/qual-p specqual).
- span — Type (spanp span).
- new-parstate — Type (parstatep new-parstate), given (parstatep parstate).
This is one of the elements of
specifier-qualifier-list in the ABNF grammar;
the grammar does not have a rule name for that.
But this is like an alternation of
a type specifier, a type qualifier, or an alignment specifier.
This function is called when we expect a specifier or qualifier,
which is the case at the start of a specifier and qualifier list
(because the list cannot be empty),
and when the caller parse-specifier-qualifier-list
determines that there must be another specifier or qualifier.
There is an overlap in the tokens that may start the three cases of
type specifiers, type qualifiers, and alignment specifiers:
the _Atomic keyword could start a type specifier,
in which case it must be followed by a parenthesized type name,
or it could be a type qualifier (as is).
So we cannot simply look at the next token
and call separate functions to parse
a type specifier or a type qualifier or an alignment specifier.
We need to read more tokens if we see _Atomic,
but if we find a parenthesized identifier after that,
it could be a type name, forming an atomic type specifier,
but it could instead be a declarator following an atomic type qualifier
(if the boolean flag passed to this function is t).
However, we can exploit the fact discussed in
parse-declaration-specifiers,
using the flag also discussed there.
If the flag is t, the _Atomic must be a type qualifier;
if the flag is nil,
and an open parenthesis follows the _Atomic,
since no specifier or qualifier may start with an open parenthesis,
the _Atomic must start a type specifier,
so we must parse a type name after the open parenthesis,
and finally the closing parenthesis.