Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
yacc(1) OSS Shell and Utilities Reference Manual
NAME
yacc - Generates an LR(1) parsing program from input
SYNOPSIS
yacc [-vltds][-b prefix][-N number][-p symbol_prefix][-P pathname] grammar
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.
FLAGS
-b prefix Uses prefix instead of y as the prefix for all output filenames (prefix.tab.c, prefix.tab.h,
and prefix.output).
-d Produces the y.tab.h file, which contains the #define statements that associate the
yacc-assigned token codes with your token 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.
-N number
Provides yacc with extra storage for building its LALR tables, which may be necessary
when compiling very large grammars. number should be larger than 40,000 when you
use this flag.
-p symbol_prefix
Allows multiple yacc parsers to be linked together. Use symbol_prefix instead of yy to
prefix global symbols.
-P pathname
Specifies an alternative parser (instead of /usr/ccs/lib/yaccpar). pathname specifies
the filename of the skeleton to be used in place of yaccpar.
-s Breaks the yyparse() function into several smaller functions. Because its size is some-
what proportional to that of the grammar, it is possible for yyparse() to become too
large to compile, optimize, or execute efficiently.
-t Compiles runtime debugging code. By default, this code is not included when y.tab.c
is compiled. If YYDEBUG has a nonzero value, the C compiler (cc) includes the
debugging code, whether or not the -t flag was used. Without compiling this code,
yyparse() will run more quickly.
-v Produces the y.output file, which contains a readable description of the parsing tables
and a report on conflicts generated by grammar ambiguities.
DESCRIPTION
The yacc grammar can be ambiguous; specified precedence rules are used to resolve ambiguities.
You must compile the y.tab.c output file with a C language compiler to produce the yyparse()
function. This function must be loaded with a yylex lexical analyzer function, as well as the
main() routine and yyerror(), an error-handling routine (you must provide these routines). The
lex command is useful for creating lexical analyzers usable by yacc.
The yacc program reads its skeleton parser from the file /usr/ccs/lib/yaccpar. Use the -P flag or
the environment variable PARSER to specify another location for yacc to read from.
Syntax for yacc Input
This section contains a formal description of the yacc input file (or grammar file), which is nor-
mally named with a .y suffix. The section provides a listing of the special values, macros, and
functions recognized by yacc.
10−36 Hewlett-Packard Company 527188-003