Parse-specifier/qualifier
Parse a specifier or qualifier.
- Signature
(parse-specifier/qualifier parstate)
→
(mv erp specqual span new-parstate)
- Arguments
- 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;
if GCC extensions are enabled,
the alternation also includes attribute specifiers.
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 two cases:
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
(or an attribute specifier, if GCC extensions are enabled).
We need to read more tokens if we see _Atomic.
[C17:6.7.2.4/4] says that
an _Atomic immediately followed by a left parentheses
is interpreted as a type specifier (not a type qualifier).
Thus, we read an additional token to decide whether
we are parsing a type specifier or a type qualifier.