Expanding the syntax of "declaration-specifiers" from the C standard I get a syntax that permits many combinations of specifiers that are semantically illogical. Has anyone written a more precise syntax that permits fewer contradictory combinations? It appears the unordered nature of the syntax (presumable intended so the programmer is not burdened with having to remember an order of specifiers) makes this complicated. It would help if there some notation for specifying "any of a choice of specifiers but only one occurance of each of a choice is allowed" (that isn't particularly well worded). Or am I barking up the wrong tree? if, for example, there is a nice concise set of semantic rules that specify which combinations are (not) permitted together. From my interpretation of the C standard the syntax is
declaration-specifiers: (storage-class-specifier|type-specifier|type-qualifier|function-specifier|alignment-specifier)+
storage-class-specifier: 'typedef'|'extern'|'static'|'_Thread_local'|'auto'|'register'
type-specifier: 'void'|'char'|'short'|'int'|'long'|'float'|'double'|'signed'|'unsigned'|'_Bool'|'_Complex' | '_Atomic' '(' type-name ')' | struct-or-union-specifier | enum-specifier | typedef-name
type-qualifier: 'const'|'restrict'|'volatile'|'_Atomic'
function-specifier: 'inline' | '_Noreturn'
alignment-specifier: '_Alignas' '(' type-name | constant-expression ')'