Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents

yacc(1) OSS Shell and Utilities Reference Manual
At least one member should be an int. Any valid C data type can be defined,
including structures. When you run yacc with the -d option, the definition of
yylval is placed in the y.tab.h file and can be referred to in a lex input file.
Every token (non-terminal symbol) must be listed in one of the preceding
% definitions. Multi-
ple tokens can be separated by white space or commas. All the tokens in %left, %right, and
%nonassoc definitions are assigned a precedence, with tokens in later definitions having pre-
cedence over those in earlier definitions.
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 first
symbol must be the first 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 definitions.
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 specific 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 definitions section.
The specially defined 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 file, the parser exits with an error message upon encountering
10−38 Hewlett-Packard Company 527188-003