yacc Command Purpose Generates an LR(1) parsing program from input consisting of a context-free grammar specification. Syntax yacc [ -bPrefix ] [ -d ] [ -l ] [ -NnNumber ] [ -NmNumber ] [ -pPath ] [ -s ] [ -t ] [ -v ] Grammar Description The yacc command converts a context-free grammar specification into a set of tables for a simple automaton that executes an LR(1) parsing algorithm. The grammar can be ambiguous; specified precedence rules are used to break ambiguities. You must compile the output file, y.tab.c, with a C Language com- piler to produce a yyparse function. This function must be load- ed with the yylex lexical analyzer, as well as the main subrou- tine and the yyerror error-handling subroutine (you must provide these subroutines). The lex command is useful for creating lexi- cal analyzers usable by the yyparse subroutine. You can compile the yacc-generated C file (y.tab.c) with the -DYACC_MSG option to include code necessary to use the Message Facility. When you use this option during compilation, error messages generated by the yyparse subroutine and the YYBACKUP macro are extracted from the yacc_user.cat catalog. This allows you to receive error messages in languages other than English in non-English locales. If the catalog cannot be found or opened, the yyparse and YYBACKUP subroutines display the de- fault English messages. The yacc command is affected by the LANG, LC_ALL, LC_CTYPE, and LC_MESSAGES environment variables. Flags -bPrefix Use Prefix instead of y as the prefix for all output file names. The code file y.tab.c, the header file y.tab.h (created when -d is specified), and the description file y.output (created when -v is specified), are changed to Prefix.tab.c, Prefix.tab.h, and Prefix.output, respectively. -d Produces the file y.tab.h. This contains the #define state- ments that associate the yacc-assigned token codes with your to- ken names. This allows source files other than y.tab.c to access the token codes by including this header file. -l Does not include any #line constructs in y.tab.c. Use this only after the grammar and associated actions are fully debugged. -NnNumber Changes the size of the token and nonterminal names ar- ray to Number. The default value is 8000. Valid values are only those greater than 8000. -NmNumber Changes the size of the memory states array to Number. Default value is 40,000. Valid values are only those greater than 40,000. -pPath Uses the parser prototype specified by the Path instead of the default /usr/lib/yaccpar file. The yyparse, yylex, and yyerror subroutine names are affected by this flag, as are the variable names yylval, yychar, and yydebug. Other subroutine and external variable names may be also be affected by this flag. -s Breaks the yyparse function into several smaller functions. Since its size is somewhat proportional to that of the grammar, it is possible for the yyparse function to become too large to compile, optimize, or execute efficiently. -t Compiles run-time debugging code. By default, this code is not included when y.tab.c is compiled. However, the run-time de- bugging code is under the control of YYDEBUG, a global variable for the cc command preprocessor. If YYDEBUG has a nonzero value, the C compiler (cc) includes the debugging code, regardless of whether the -t flag is used. YYDEBUG should have a value of 0 if you don't want the debugging code included by the compiler. Without compiling this code, the yyparse subroutine will have a faster operating speed. -v Prepares the file y.output. It contains a readable descrip- tion of the parsing tables and a report on conflicts generated by grammar ambiguities. Exit Status This command returns the following exit values: 0 Successful completion. >0 An error occurred. Examples 1. The following command: yacc grammar.y draws yacc rules from the grammar.y file, and places the output in y.tab.c. 2. The following command: yacc -d grammar.y functions as Example 1, but it also produces the y.tab.h file which would contain C-style #define statements for each of the tokens defined in the grammar.y file. Files y.output A readable description of the parsing tables and a re- port on conflicts generated by grammar ambiguities. y.tab.c Output file. y.tab.h Definitions for token names. yacc.tmp Temporary file. yacc.debug Temporary file. yacc.acts Temporary file. /usr/ccs/lib/yaccpar Parser prototype for C programs. /usr/ccs/lib/liby.a Runtime library. Implementation Specifics This command is part of Application Development Toolkit in Base Application Development Toolkit. Related Information Creating an Input Language with the lex and yacc Commands in AIX Version 3.2 General Programming Concepts. The lex command. The Example program for the lex and yacc programs in AIX Version 3.2 General Programming Concepts.