Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)

yacc(1) OSS Shell and Utilities Reference Manual
At least one member should be an int. Any valid C data type can be dened,
including structures. When you run yacc with the -d option, the denition of
yylval is placed in the y.tab.h le and can be referred to in a lex input le.
Every token (non-terminal symbol) must be listed in one of the preceding
% denitions. Multi-
ple tokens can be separated by white space or commas. All the tokens in %left, %right, and
%nonassoc denitions are assigned a precedence, with tokens in later denitions having pre-
cedence over those in earlier denitions.
In addition to symbols, a token can be a literal character enclosed in single quotes. (Multibyte
characters are recognized by the lexical analyzer and returned as tokens.) The following special
characters can be used, just as in C programs:
\a Alert
\n Newline
\t Tab
\v Vertical tab
\r Carriage return
\b Backspace
\f Formfeed
\\ Backslash
\ Single quote
\? Question mark
\n One or more octal digits specifying the integer value of the character
The rules section consists of a series of production rules that the parser tries to reduce. The for-
mat of each production rule is:
symbol : symbol-sequence
[ action ][ symbol-sequence
[ action ] ... ] ;
where symbol-sequence consists of zero or more symbols separated by white space. The rst
symbol must be the rst character of the line, but new lines and other white space can appear
anywhere else in the rule. All terminal symbols must be declared in %token denitions.
Each symbol-sequence represents an alternative way of reducing the rule. A symbol can appear
recursively in its own rule. Always use left-recursion (where the recursive symbol appears
before the terminating case in symbol-sequence).
The specic sequence:
%prec token
indicates that the current sequence of symbols is to be preferred over others, at the level of pre-
cedence assigned to token in the denitions section.
The specially dened token error matches any unrecognized sequence of input. This token
causes the parser to invoke the yyerror function. By default, the parser tries to synchronize with
the input and continue processing it by reading and discarding all input up to the symbol follow-
ing error. (You can override this behavior through the yyerrok action.) If no error token
appears in the yacc input le, the parser exits with an error message upon encountering
1038 Hewlett-Packard Company 527188-007