|
|
1.1 ! root 1: .TH YACC 1 ! 2: .SH NAME ! 3: yacc \- yet another compiler-compiler ! 4: .SH SYNOPSIS ! 5: .B yacc ! 6: [ ! 7: .I option ... ! 8: ] ! 9: .I grammar ! 10: .SH DESCRIPTION ! 11: .I Yacc ! 12: converts a context-free grammar and translation code ! 13: into a set of ! 14: tables for an LR(1) parser and translator. ! 15: The grammar may be ambiguous; ! 16: specified precedence rules are used to break ambiguities. ! 17: .PP ! 18: The output file, ! 19: .BR y.tab.c , ! 20: must be compiled by the C compiler ! 21: to produce a program ! 22: .LR yyparse . ! 23: This program must be loaded with a lexical analyzer function, ! 24: .B yylex(void) ! 25: (often generated by ! 26: .IR lex (1)), ! 27: with a ! 28: .B main(int argc, char *argv[]) ! 29: program, and with an error handling routine, ! 30: .BR yyerror(char*) . ! 31: .PP ! 32: The options are ! 33: .TP "\w'\fL-o \fIoutput\fLXX'u" ! 34: .BI -o " output ! 35: Direct output to the specified file instead of ! 36: .BR y.tab.c . ! 37: .TP ! 38: .BI -D n ! 39: Create file ! 40: .BR y.debug , ! 41: containing diagnostic messages. ! 42: To incorporate them in the parser, compile it with preprocessor symbol ! 43: .B YYDEBUG ! 44: defined. ! 45: The amount of ! 46: diagnostic output from the parser is regulated by ! 47: value ! 48: .IR n : ! 49: .RS ! 50: .TP ! 51: 0 ! 52: Report errors. ! 53: .TP ! 54: 1 ! 55: Also report reductions. ! 56: .TP ! 57: 2 ! 58: Also report the name of each token returned by ! 59: .LR yylex . ! 60: .RE ! 61: .TP ! 62: .B -v ! 63: Create file ! 64: .BR y.output , ! 65: containing a description of the parsing tables and of ! 66: conflicts arising from ambiguities in the grammar. ! 67: .TP ! 68: .B -d ! 69: Create file ! 70: .BR y.tab.h , ! 71: containing ! 72: .B #define ! 73: statements that associate ! 74: .IR yacc -assigned ! 75: `token codes' with user-declared `token names'. ! 76: Include it in source files other than ! 77: .B y.tab.c ! 78: to give access to the token codes. ! 79: .TP ! 80: .BI -s " stem ! 81: Change the prefix ! 82: .L y ! 83: of the file names ! 84: .BR y.tab.c , ! 85: .BR y.tab.h , ! 86: .BR y.debug , ! 87: and ! 88: .B y.output ! 89: to ! 90: .IR stem . ! 91: .TP ! 92: .B -S ! 93: Write a parser that uses ! 94: Stdio ! 95: instead of the ! 96: .B print ! 97: routines in libc. ! 98: .PP ! 99: The specification of ! 100: .I yacc ! 101: itself is essentially the same as the UNIX version ! 102: described in the references mentioned below. ! 103: Besides the ! 104: .B -D ! 105: option, the main relevant differences are: ! 106: .IP ! 107: The interface to the C environment is by default through ! 108: .B <libc.h> ! 109: rather than ! 110: .BR <stdio.h> ; ! 111: the ! 112: .B -S ! 113: option reverses this. ! 114: .IP ! 115: The parser accepts ! 116: .SM UTF ! 117: input text (see ! 118: .IR utf (6)), ! 119: which has a couple of effects. ! 120: First, the return value of ! 121: .B yylex() ! 122: no longer fits in a ! 123: .BR short ; ! 124: second, the starting value for non-terminals is now 0xE000 rather than 257. ! 125: .IP ! 126: The generated parser can be recursive: actions can call ! 127: .IR yyparse , ! 128: for example to implement a sort of ! 129: .B #include ! 130: statement in an interpreter. ! 131: .IP ! 132: Finally, some undocumented inner workings of the parser have been ! 133: changed, which may affect programs that know too much about its structure. ! 134: .SH FILES ! 135: .TF /sys/lib/yaccpars ! 136: .TP ! 137: .B y.output ! 138: .TP ! 139: .B y.tab.c ! 140: .TP ! 141: .B y.tab.h ! 142: .TP ! 143: .B y.debug ! 144: .TP ! 145: .B y.tmp.* ! 146: temporary file ! 147: .TP ! 148: .B y.acts.* ! 149: temporary file ! 150: .TP ! 151: .B /sys/lib/yaccpar ! 152: parser prototype ! 153: .TP ! 154: .B /sys/lib/yaccpars ! 155: parser prototype using stdio ! 156: .SH SOURCE ! 157: .B /sys/src/cmd/yacc.c ! 158: .SH "SEE ALSO" ! 159: .IR lex (1) ! 160: .br ! 161: S. C. Johnson and R. Sethi, ! 162: ``Yacc: A parser generator'', ! 163: .I ! 164: Unix Research System Programmer's Manual, ! 165: Tenth Edition, Volume 2 ! 166: .br ! 167: B. W. Kernighan and Rob Pike, ! 168: .I ! 169: The UNIX Programming Environment, ! 170: Prentice Hall, 1984 ! 171: .SH BUGS ! 172: The parser may not have full information when it writes to ! 173: .B y.debug ! 174: so that the names of the tokens returned by ! 175: .L yylex ! 176: may be missing.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.