.TH YACC 1 .SH NAME yacc, eyacc \- yet another compiler-compiler .SH SYNOPSIS .B yacc [ .B \-vdD ] [ .B \-o output ] [ .B \-s stem ] grammar .PP .B eyacc [ .B \-v ] [ grammar ] .SH DESCRIPTION .I yacc converts a context-free grammar into a set of tables for a simple automaton which executes an LR(1) parsing algorithm. The grammar may be ambiguous; specified precedence rules are used to break ambiguities. .PP The output file, .IR y.tab.c , must be compiled by the C compiler to produce a program .IR yyparse . The output file name can be set with the .B \-o flag. This program must be loaded with the lexical analyzer program, .IR yylex , as well as .I main and .IR yyerror , an error handling routine. These routines must be supplied by the user; .IR lex (1) is useful for creating lexical analyzers usable by .IR yacc . .PP If the .B \-D flag is given, .I yacc creates .IR y.debug , which contains default error messages for the parser. The parser will use them if it is compiled with the preprocessor symbol .I YYDEBUG defined. The amount of diagnostic output is controlled by an external variable .IR yydebug . If it is 2, the parser prints out the name of each token returned by .I yylex and each reduction. If it is 1, the parser prints out the reductions, and if it is 0, the parser only reports errors. .PP If the .B \-v flag is given, the file .I y.output is prepared, which contains a description of the parsing tables and a report on conflicts generated by ambiguities in the grammar. .PP If the \-\fBd\fR flag is used, the file .I y.tab.h is generated with the .I define statements that associate the .I yacc\c -assigned `token codes' with the user-declared `token names'. This allows source files other than .I y.tab.c to access the token codes. .PP The prefix .I y. for the files .I y.tab.c .IR y.tab.h , .IR y.debug , and .I y.output can be changed to .I stem by the .B \-s flag. .PP .I eyacc is an old version of .I yacc, with systematic error recovery. It is used in .IR pascal (1). .SH FILES .ta \w'y.acts.?????? 'u y.output .br y.tab.c .br y.tab.h defines for token names .br y.debug .br y.tmp.?????? temporary file .br y.acts.????? temporary file .br /usr/lib/yaccpar parser prototype for C programs .br /lib/liby.a library with default `main' and `yyerror' .SH "SEE ALSO" .IR lex (1) .br .I "LR Parsing" by A. V. Aho and S. C. Johnson, Computing Surveys, June, 1974. .br .I "YACC \- Yet Another Compiler Compiler" by S. C. Johnson. .br Susan L. Graham, Charles B. Haley, and W. N. Joy, .I "Practical LR Error Recovery," SIGPLAN Conference on Compiler Construction, August, 1979. .SH DIAGNOSTICS The number of reduce-reduce and shift-reduce conflicts is reported on the standard output; a more detailed report is found in the .I y.output file. Similarly, if some rules are not reachable from the start symbol, this is also reported. .SH BUGS The parser may not have full information when it prints out .I y.debug so that the names of the tokens returned by .I yylex may be missing.