2 .\" Copyright 1989 AT&T Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/.
4 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text
5 .\" are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical
6 .\" and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
7 .\" This notice shall appear on any product containing this material.
8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
9 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
10 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
11 .TH YACC 1 "Aug 24, 2009"
13 yacc \- yet another compiler-compiler
17 \fByacc\fR [\fB-dltVv\fR] [\fB-b\fR \fIfile_prefix\fR] [\fB-Q\fR [y | n]]
18 [\fB-P\fR \fIparser\fR] [\fB-p\fR \fIsym_prefix\fR] \fIfile\fR
24 The \fByacc\fR command converts a context-free grammar into a set of tables for
25 a simple automaton that executes an LALR(1) parsing algorithm. The grammar can
26 be ambiguous. Specified precedence rules are used to break ambiguities.
29 The output file, \fBy.tab.c\fR, must be compiled by the C compiler to produce a
30 function \fByyparse()\fR. This program must be loaded with the lexical analyzer
31 program, \fByylex()\fR, as well as \fBmain()\fR and \fByyerror()\fR, an error
32 handling routine. These routines must be supplied by the user. The \fBlex\fR(1)
33 command is useful for creating lexical analyzers usable by \fByacc\fR.
37 The following options are supported:
41 \fB\fB-b\fR \fIfile_prefix\fR\fR
44 Uses \fIfile_prefix\fR instead of \fBy\fR as the prefix for all output files.
45 The code file \fBy.tab.c\fR, the header file \fBy.tab.h\fR (created when
46 \fB-d\fR is specified), and the description file \fBy.output\fR (created when
47 \fB-v\fR is specified), is changed to \fIfile_prefix\fR\fB\&.tab.c\fR,
48 \fIfile_prefix\fR\fB\&.tab.h\fR, and \fIfile_prefix\fR\fB\&.output\fR,
58 Generates the file \fBy.tab.h\fR with the \fB#define\fR statements that
59 associate the \fByacc\fR user-assigned "token codes" with the user-declared
60 "token names". This association allows source files other than \fBy.tab.c\fR to
61 access the token codes.
70 Specifies that the code produced in \fBy.tab.c\fR does not contain any
71 \fB#line\fR constructs. This option should only be used after the grammar and
72 the associated actions are fully debugged.
78 \fB\fB-p\fR \fIsym_prefix\fR\fR
81 Uses \fIsym_prefix\fR instead of \fByy\fR as the prefix for all external names
82 produced by \fByacc\fR. The names affected include the functions
83 \fByyparse()\fR, \fByylex()\fR and \fByyerror()\fR, and the variables
84 \fIyylval\fR, \fIyychar\fR and \fIyydebug\fR. (In the remainder of this
85 section, the six symbols cited are referenced using their default names only as
86 a notational convenience.) Local names can also be affected by the \fB-p\fR
87 option. However, the \fB-p\fR option does not affect \fB#define\fR symbols
88 generated by \fByacc\fR.
94 \fB\fB-P\fR \fIparser\fR\fR
97 Allows you to specify the parser of your choice instead of
98 \fB/usr/share/lib/ccs/yaccpar\fR. For example, you can specify:
102 example% \fByacc -P ~/myparser parser.y\fR
112 \fB\fB-Q\fR[\fBy\fR|\fBn\fR]\fR
115 The \fB-Qy\fR option puts the version stamping information in \fBy.tab.c\fR.
116 This allows you to know what version of \fByacc\fR built the file. The
117 \fB-Qn\fR option (the default) writes no version information.
126 Compiles runtime debugging code by default. Runtime debugging code is always
127 generated in \fBy.tab.c\fR under conditional compilation control. By default,
128 this code is not included when \fBy.tab.c\fR is compiled. Whether or not the
129 \fB-t\fR option is used, the runtime debugging code is under the control of
130 \fBYYDEBUG\fR , a preprocessor symbol. If \fBYYDEBUG\fR has a non-zero value,
131 then the debugging code is included. If its value is \fB0\fR, then the code is
132 not included. The size and execution time of a program produced without the
133 runtime debugging code is smaller and slightly faster.
142 Prepares the file \fBy.output\fR, which contains a description of the parsing
143 tables and a report on conflicts generated by ambiguities in the grammar.
152 Prints on the standard error output the version information for \fByacc\fR.
158 The following operand is required:
165 A path name of a file containing instructions for which a parser is to be
171 \fBExample 1 \fRAccessing the yacc Library
174 Access to the \fByacc\fR library is obtained with library search operands to
175 \fBcc\fR. To use the \fByacc\fR library \fBmain\fR:
180 example% \fBcc y.tab.c -ly\fR
187 Both the \fBlex\fR library and the \fByacc\fR library contain \fBmain\fR. To
188 access the \fByacc\fR \fBmain\fR:
193 example% \fBcc y.tab.c lex.yy.c -ly -ll\fR
200 This ensures that the \fByacc\fR library is searched first, so that its
205 The historical \fByacc\fR libraries have contained two simple functions that
206 are normally coded by the application programmer. These library functions are
207 similar to the following code:
215 extern int yyparse();
217 setlocale(LC_ALL, "");
219 /* If the following parser is one created by lex, the
220 application must be careful to ensure that LC_CTYPE
221 and LC_COLLATE are set to the POSIX locale. */
228 int yyerror(const char *msg)
230 (void) fprintf(stderr, "%s\en", msg);
236 .SH ENVIRONMENT VARIABLES
239 See \fBenviron\fR(5) for descriptions of the following environment variables
240 that affect the execution of \fByacc\fR: \fBLANG\fR, \fBLC_ALL\fR,
241 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
244 \fByacc\fR can handle characters from \fBEUC\fR primary and supplementary
245 codesets as one-token symbols. \fBEUC\fR codes can only be single character
246 quoted terminal symbols. \fByacc\fR expects \fByylex()\fR to return a wide
247 character (\fBwchar_t\fR) value for these one-token symbols.
251 The following exit values are returned:
258 Successful completion.
277 state transitions of the generated parser
286 source code of the generated parser
295 header file for the generated parser
301 \fB\fByacc.acts\fR\fR
310 \fB\fByacc.debug\fR\fR
331 parser prototype for C programs
337 See \fBattributes\fR(5) for descriptions of the following attributes:
345 ATTRIBUTE TYPE ATTRIBUTE VALUE
347 Interface Stability Committed
349 Standard See \fBstandards\fR(5).
355 \fBlex\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)
359 The number of reduce-reduce and shift-reduce conflicts is reported on the
360 standard error output. A more detailed report is found in the \fBy.output\fR
361 file. Similarly, if some rules are not reachable from the start symbol, this
362 instance is also reported.
366 Because file names are fixed, at most one \fByacc\fR process can be active in a
367 given directory at a given time.
370 Users are encouraged to avoid using \fB$\fR as part of any identifier name.