Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)

yacc(1) OSS Shell and Utilities Reference Manual
NAME
yacc - Generates an LR(1) parsing program from input
SYNOPSIS
yacc [-vltds][-b prex][-N number][-p symbol_prex][-P pathname] grammar
The yacc command converts a context-free grammar specication into a set of tables for a
simple automaton that executes an LR(1) parsing algorithm.
FLAGS
-b prefix Uses prex instead of y as the prex for all output lenames (prex.tab.c, prex.tab.h,
and prex.output).
-d Produces the y.tab.h le, which contains the #dene statements that associate the
yacc-assigned token codes with your token names. This allows source les other than
y.tab.c to access the token codes by including this header le.
-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 ag.
-p symbol_prefix
Allows multiple yacc parsers to be linked together. Use symbol_prex instead of yy to
prex global symbols.
-P pathname
Species an alternative parser (instead of /usr/ccs/lib/yaccpar). pathname species
the lename 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 efciently.
-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 ag was used. Without compiling this code,
yyparse() will run more quickly.
-v Produces the y.output le, which contains a readable description of the parsing tables
and a report on conicts generated by grammar ambiguities.
DESCRIPTION
The yacc grammar can be ambiguous; specied precedence rules are used to resolve ambiguities.
You must compile the y.tab.c output le 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 le /usr/ccs/lib/yaccpar. Use the -P ag 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 le (or grammar le), which is nor-
mally named with a .y sufx. The section provides a listing of the special values, macros, and
functions recognized by yacc.
1036 Hewlett-Packard Company 527188-007