| 1 | .TH YACC 1 |
| 2 | .SH NAME |
| 3 | yacc \- yet another compiler-compiler |
| 4 | .SH SYNOPSIS |
| 5 | .B yacc |
| 6 | [ |
| 7 | .B \-vd |
| 8 | ] |
| 9 | grammar |
| 10 | .SH DESCRIPTION |
| 11 | .I Yacc |
| 12 | converts a context-free grammar into a set of |
| 13 | tables for a simple automaton which executes an LR(1) parsing |
| 14 | algorithm. |
| 15 | The grammar may be ambiguous; |
| 16 | specified precedence rules are used to break ambiguities. |
| 17 | .PP |
| 18 | The output file, |
| 19 | .IR y.tab.c , |
| 20 | must be compiled by the C compiler |
| 21 | to produce a program |
| 22 | .IR yyparse . |
| 23 | This program must be loaded with the lexical analyzer program, |
| 24 | .IR yylex , |
| 25 | as well as |
| 26 | .I main |
| 27 | and |
| 28 | .IR yyerror , |
| 29 | an error handling routine. |
| 30 | These routines must be supplied by the user; |
| 31 | .IR Lex (1) |
| 32 | is useful for creating lexical analyzers usable by |
| 33 | .IR yacc . |
| 34 | .PP |
| 35 | If the |
| 36 | .B \-v |
| 37 | flag is given, the file |
| 38 | .I y.output |
| 39 | is prepared, which contains a description of the parsing tables |
| 40 | and a report on |
| 41 | conflicts generated by ambiguities in the grammar. |
| 42 | .PP |
| 43 | If the \-\fBd\fR flag is used, the file |
| 44 | .I y.tab.h |
| 45 | is generated with the |
| 46 | .I define |
| 47 | statements that associate the |
| 48 | .I yacc\c |
| 49 | -assigned `token codes' with the user-declared `token names'. |
| 50 | This allows source files other than |
| 51 | .I y.tab.c |
| 52 | to access the token codes. |
| 53 | .SH FILES |
| 54 | .ta \w'yacc.tmp, yacc.acts 'u |
| 55 | y.output |
| 56 | .br |
| 57 | y.tab.c |
| 58 | .br |
| 59 | y.tab.h defines for token names |
| 60 | .br |
| 61 | yacc.tmp, yacc.acts temporary files |
| 62 | .br |
| 63 | /usr/lib/yaccpar parser prototype for C programs |
| 64 | .br |
| 65 | /lib/liby.a library with default `main' and `yyerror' |
| 66 | .SH "SEE ALSO" |
| 67 | .IR lex (1) |
| 68 | .br |
| 69 | .I "LR Parsing" |
| 70 | by A. V. Aho and S. C. Johnson, |
| 71 | Computing Surveys, June, 1974. |
| 72 | .br |
| 73 | .I "YACC \- Yet Another Compiler Compiler" |
| 74 | by S. C. Johnson. |
| 75 | .SH DIAGNOSTICS |
| 76 | The number of reduce-reduce and shift-reduce conflicts |
| 77 | is reported on the standard output; |
| 78 | a more detailed report is |
| 79 | found in the |
| 80 | .I y.output |
| 81 | file. |
| 82 | Similarly, if some rules are not reachable from the |
| 83 | start symbol, this is also reported. |
| 84 | .SH BUGS |
| 85 | Because file names are fixed, at most one |
| 86 | .I yacc |
| 87 | process can be active in a given directory at |
| 88 | a time. |