diff options
Diffstat (limited to 'man/man1/yacc.html')
-rw-r--r-- | man/man1/yacc.html | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/man/man1/yacc.html b/man/man1/yacc.html new file mode 100644 index 00000000..1a485ce6 --- /dev/null +++ b/man/man1/yacc.html @@ -0,0 +1,170 @@ +<head> +<title>yacc(1) - Plan 9 from User Space</title> +<meta content="text/html; charset=utf-8" http-equiv=Content-Type> +</head> +<body bgcolor=#ffffff> +<table border=0 cellpadding=0 cellspacing=0 width=100%> +<tr height=10><td> +<tr><td width=20><td> +<tr><td width=20><td><b>YACC(1)</b><td align=right><b>YACC(1)</b> +<tr><td width=20><td colspan=2> + <br> +<p><font size=+1><b>NAME </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + yacc – yet another compiler-compiler<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>yacc</font></tt> [ <i>option ...</i> ] <i>grammar<br> + </i> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Yacc</i> 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. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The output file, <tt><font size=+1>y.tab.c</font></tt>, must be compiled by the C compiler to + produce a program <tt><font size=+1>yyparse</font></tt>. This program must be loaded with a + lexical analyzer function, <tt><font size=+1>yylex(void)</font></tt> (often generated by <a href="../man1/lex.html"><i>lex</i>(1)</a>), + with a <tt><font size=+1>main(int argc, char *argv[])</font></tt> program, and with an error + handling routine, + <tt><font size=+1>yyerror(char*)</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The options are<br> + <tt><font size=+1>−o</font></tt> <i>output</i> Direct output to the specified file instead of <tt><font size=+1>y.tab.c</font></tt>.<br> + <tt><font size=+1>−D</font></tt><i>n</i> Create file <tt><font size=+1>y.debug</font></tt>, containing diagnostic messages. To incorporate + them in the parser, compile it with preprocessor symbol <tt><font size=+1>yydebug</font></tt> + defined. The amount of diagnostic output from the parser is regulated + by value <i>n</i>. The value 0 reports errors; 1 reports reductions; + higher values (up to 4) include + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + more information about state transitions.<br> + + </table> + + </table> + <tt><font size=+1>−v</font></tt> Create file <tt><font size=+1>y.output</font></tt>, containing a description of the parsing + tables and of conflicts arising from ambiguities in the grammar.<br> + <tt><font size=+1>−d</font></tt> Create file <tt><font size=+1>y.tab.h</font></tt>, containing <tt><font size=+1>#define</font></tt> statements that associate + <i>yacc</i>-assigned ‘token codes’ with user-declared ‘token names’. + Include it in source files other than <tt><font size=+1>y.tab.c</font></tt> to give access to + the token codes.<br> + <tt><font size=+1>−s</font></tt> <i>stem</i> Change the prefix <tt><font size=+1>y</font></tt> of the file names <tt><font size=+1>y.tab.c</font></tt>, <tt><font size=+1>y.tab.h</font></tt>, + <tt><font size=+1>y.debug</font></tt>, and <tt><font size=+1>y.output</font></tt> to <i>stem</i>.<br> + <tt><font size=+1>−S</font></tt> Write a parser that uses Stdio instead of the <tt><font size=+1>print</font></tt> routines + in libc. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The specification of <i>yacc</i> itself is essentially the same as the + UNIX version described in the references mentioned below. Besides + the <tt><font size=+1>−D</font></tt> option, the main relevant differences are:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The interface to the C environment is by default through <tt><font size=+1><libc.h></font></tt> + rather than <tt><font size=+1><stdio.h></font></tt>; the <tt><font size=+1>−S</font></tt> option reverses this.<br> + The parser accepts UTF input text (see <a href="../man7/utf.html"><i>utf</i>(7)</a>), which has a couple + of effects. First, the return value of <tt><font size=+1>yylex()</font></tt> no longer fits + in a <tt><font size=+1>short</font></tt>; second, the starting value for non-terminals is now + 0xE000 rather than 257.<br> + The generated parser can be recursive: actions can call <i>yyparse</i>, + for example to implement a sort of <tt><font size=+1>#include</font></tt> statement in an interpreter.<br> + Finally, some undocumented inner workings of the parser have been + changed, which may affect programs that know too much about its + structure.<br> + + </table> + +</table> +<p><font size=+1><b>FILES </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>y.output<br> + y.tab.c<br> + y.tab.h<br> + y.debug<br> + y.tmp.*</font></tt> temporary file<br> + <tt><font size=+1>y.acts.*</font></tt> temporary file<br> + <tt><font size=+1>/usr/local/plan9/lib/yaccpar<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + parser prototype<br> + + </table> + + </table> + <tt><font size=+1>/usr/local/plan9/lib/yaccpars<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + parser prototype using stdio<br> + + </table> + + </table> + +</table> +<p><font size=+1><b>SOURCE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>/usr/local/plan9/src/cmd/yacc.c<br> + </font></tt> +</table> +<p><font size=+1><b>SEE ALSO </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <a href="../man1/lex.html"><i>lex</i>(1)</a><br> + S. C. Johnson and R. Sethi, “Yacc: A parser generator”, <i>Unix Research + System Programmer’s Manual,</i> Tenth Edition, Volume 2<br> + B. W. Kernighan and Rob Pike, <i>The UNIX Programming Environment,</i> + Prentice Hall, 1984<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The parser may not have full information when it writes to <tt><font size=+1>y.debug</font></tt> + so that the names of the tokens returned by <tt><font size=+1>yylex</font></tt> may be missing.<br> + +</table> + +<td width=20> +<tr height=20><td> +</table> +<!-- TRAILER --> +<table border=0 cellpadding=0 cellspacing=0 width=100%> +<tr height=15><td width=10><td><td width=10> +<tr><td><td> +<center> +<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> +</center> +</table> +<!-- TRAILER --> +</body></html> |