A.13 Grammar
Below is a recapitulation of the grammar that was given throughout the earlier part of this appendix. It has exactly the same content, but is in different order.
The grammar has undefined terminal symbols integer-constant, character-constant, floating-constant, identifier, string, and enumeration-constant; the typewriter style words and symbols are terminals given literally. This grammar can be transformed mechanically into input acceptable for an automatic parser-generator. Besides adding whatever syntactic marking is used to indicate alternatives in productions, it is necessary to expand the one of constructions, and (depending on the rules of the parser-generator) to duplicate each production with an opt symbol, once with the symbol and once without. With one further change, namely deleting the production typedef-name: identifier and making typedef-name a terminal symbol, this grammar is acceptable to the YACC parser-generator. It has only one conflict, generated by the if-else ambiguity. = *= /= %= += -= <<= >>= &= ^= |= logical-OR-expression || logical-AND-expression logical-AND-expression && inclusive-OR-expression AND-expression & equality-expression relational-expression < shift-expression relational-expression > shift-expression relational-expression <= shift-expression relational-expression >= shift-expression shift-expression << additive-expression shift-expression >> additive-expression & * + - ~ ! postfix-expression->+identifier postfix-expression++ postfix-expression-- The following grammar for the preprocessor summarizes the structure of control lines, but is not suitable for mechanized parsing. It includes the symbol text, which means ordinary program text, non-conditional preprocessor control lines, or complete preprocessor conditional instructions. # include <filename> # include "filename" # line constant "filename" # line constant # error token-sequenceopt # pragma token-sequenceopt # preprocessor-conditional
external-declaration:
function-definition:
declaration:
declaration-list:
declaration-specifiers:
storage-class specifier: one of
type specifier: one of
type-qualifier: one of
struct-or-union-specifier:
struct-or-union: one of
struct-declaration-list:
init-declarator-list:
init-declarator:
struct-declaration:
specifier-qualifier-list:
struct-declarator-list:
struct-declarator:
enum-specifier:
enumerator-list:
enumerator:
declarator:
direct-declarator:
pointer:
type-qualifier-list:
parameter-type-list:
parameter-list:
parameter-declaration:
identifier-list:
initializer:
initializer-list:
type-name:
abstract-declarator:
direct-abstract-declarator:
typedef-name:
statement:
labeled-statement:
expression-statement:
compound-statement:
statement-list:
selection-statement:
iteration-statement:
jump-statement:
expression:
assignment-expression:
assignment-operator: one of
conditional-expression:
constant-expression:
logical-OR-expression:
logical-AND-expression:
inclusive-OR-expression:
exclusive-OR-expression:
AND-expression:
equality-expression:
relational-expression:
shift-expression:
additive-expression:
multiplicative-expression:
cast-expression:
unary-expression:
unary operator: one of
postfix-expression:
primary-expression:
argument-expression-list:
constant:
preprocessor-conditional:
if-line:
elif-parts:
elif-line:
else-part:
else-line: