converts a context-free grammar and translation code
into a set of
tables for an LR(1) parser and translator.
The grammar may be ambiguous;
specified precedence rules are used to break ambiguities.
The output file,
must be compiled by the C compiler
to produce a program
This program must be loaded with a lexical analyzer function,
(often generated by
main(int argc, char *argv)
program, and with an error handling routine,
The options are
Direct output to the specified file instead of
containing diagnostic messages.
To incorporate them in the parser, compile it with preprocessor symbol
The amount of
diagnostic output from the parser is regulated by
The value 0 reports errors; 1 reports reductions;
higher values (up to 4) include more information about
containing a description of the parsing tables and of
conflicts arising from ambiguities in the grammar.
statements that associate
`token codes' with user-declared `token names'.
Include it in source files other than
to give access to the token codes.
Change the prefix
of the file names
Write a parser that uses
instead of the
routines in libc.
Disable #line directives in the generated parser.
Generate a parser that takes an argument of type Yyarg
and passes this argument to each invocation of the lexer
function, yylex. Yyarg contains per-instance state
and a single user-visible member, arg, of type void*.
The specification of
itself is essentially the same as the UNIX version
described in the references mentioned below.
option, the main relevant differences are:
The interface to the C environment is by default through
option reverses this.
The parser accepts
input text (see
which has a couple of effects.
First, the return value of
no longer fits in a
second, the starting value for non-terminals is now 0xE000 rather than 257.
The generated parser can be recursive: actions can call
for example to implement a sort of
statement in an interpreter.
Finally, some undocumented inner workings of the parser have been
changed, which may affect programs that know too much about its structure.
parser prototype using stdio
S. C. Johnson and R. Sethi,
``Yacc: A parser generator'',
Unix Research System Programmer's Manual,
Tenth Edition, Volume 2
B. W. Kernighan and Rob Pike,
The UNIX Programming Environment,
Prentice Hall, 1984
The parser may not have full information when it writes to
so that the names of the tokens returned by
may be missing.