AT&T yacc is distributed with most versions of UNIX, except for the most recent verions of Berkeley UNIX, which have Berkeley yacc. If you’re not sure which version of yacc you have, try running it with no arguments. If it says:
fatal error: cannot open input file, line 1
it’s AT&T yacc. If it gives you a summary of the command syntax, it’s Berkeley yacc.
Yacc processes a file containing a grammar and generates source code for a parser. By convention, the grammar file has a .y extension. The file that yacc generates is named y.tab.c.
The syntax of the yacc command is:
where options are as follows:
Generates the header file y.tab.h that contains definitions of token names.
Omits #line constructs in the generated code.
Includes runtime debugging code when y.tab.c is compiled.
Produces the file y.output, which contains a listing of all of the states in the generated parser and other useful information.
In order to compile the parser generated by yacc, you must supply a main routine and a supporting routine, yyerror. The UNIX library liby.a contains default versions of these routines.
See Chapter 7, A Reference for Yacc Grammars , for information on yacc specifications.
This section discusses correcting problems and errors reported by yacc, aside from the shift/reduce and reduce/reduce errors discussed in Chapter 8, Yacc Ambiguities and Conflicts . The error messages are organized alphabetically.