The command line needed to invoke Zyacc has the format:
zyacc [Options List] yacc-file [yacc-file...]
Here yacc-file specifies the name(s) of the grammar file, usually
ending in `.y'. Unless the --output
or --yacc
options
are specified, the name of the generated parser file is created by replacing
the `.y' with `.tab.c'. Thus, the `zyacc foo.y' filename
yields `foo.tab.c', and the `zyacc hack/foo.y' filename yields
`hack/foo.tab.c'.
A word which constitutes a command-line argument has two possible types: it is a option word if it begin with a `-' or `--' (with certain exceptions noted below), or if it follows an option word which requires an argument. Otherwise it is a non-option word. An option word specifies the value of a Zyacc option; a non-option word specifies a file name.
Besides the command-line, Zyacc can read its options from several different sources. In order of increasing priority these sources are the following:
ZYACC_OPTIONS
. If this variable is set, then
its value should contain only options and option values separated by
whitespace as on the command-line. The procedure for setting environment
variables depends on the system you are using: under the UNIX shell
csh
the setenv
command can be used, under the MS-DOS
command-interpreter the set
command can be used; under the UNIX shell
sh
or ksh
the export
command can be used.
%option
directives (see section The Zyacc Declarations Section).
Options specified by the environment variable ZYACC_OPTIONS
overrides
the options specified in the `zyacc.opt' file. Options specified in the
Zyacc source file override options specified in the `zyacc.opt' file or
ZLEX_OPTIONS
environment variable. Finally, command-line options
always override options specified by all other sources.
A list of the available options follows:
--build-display
--debug[=1|0]
-t[1|0]
YYDEBUG
into the parser file,
so that the debugging facilities are compiled. See section Debugging Your Parser.
--defines[=1|0]
-d[1|0]
YYSTYPE
and C preprocessor macro definitions for all the token
type names defined in the grammar (default: 0
).
If the parser output file is named `name.c' then this file
is named `name.h'.
This output file is essential if you wish to put the definition of
yylex
in a separate source file, because yylex
needs to
be able to refer to token type codes and the variable
yylval
. See section Semantic Values of Tokens.
--file-prefix prefix
-b prefix
--grammar[=1|0]
-g[1|0]
0
).
--help
-h
--HTML[=1|0]
-H[1|0]
--verbose
option, but you can use any WWW browser like Netscape
or Lynx to browse the parser description file and follow hot links
within the file (default: 0
).
--lines
1
). If
Zyacc puts these directives in the parser file then the C compiler and
debuggers can associate errors with your source file, the grammar file. If
this option is specified as 0
, then errors will be associated with
the parser file, treating it an independent source file in its own right.
--longer-rule-prefer[=1|0]
0
). If this option is specified as 0
, then the reduce-reduce
conflicts are resolved in favor of the rule which occurs earlier in
the source file.
--output-file outFile
-o outFile
--defines
and --verbose
switches.
--name-prefix prefix
-p prefix
yychar
, yydebug
, yyerror
, yylex
,
yynerrs
, yylval
and yyparse
.
For example, if you use `-p c', the names become cchar
,
cdebug
, and so on.
See section Multiple Parsers in the Same Program.
--term-prefix suffix
""
). For example, if you specify --term-prefix _TOK
,
then the string _TOK
will be appended to all terminal names
exported from the grammar; if you use ID
as a terminal name within
your grammar, its external name will be ID_TOK
.
--verbose[=1|0]
-v[1|0]
0
). The
extra output file contains descriptions of the parser states and what is
done for each type of look-ahead token in that state.
This file also describes all the conflicts, both those resolved by
operator precedence and the unresolved ones.
The file's name is made by removing `.tab.c' or `.c' from
the parser output file name, and adding `.output' instead.
Therefore, if the input file is `foo.y', then the parser file is
called `foo.tab.c' by default. As a consequence, the verbose
output file is called `foo.output'.
--version
-V
--yacc[=1|0]
-y[1|0]
0
)
Equivalent to `-o y.tab.c'; the parser output file is called
`y.tab.c', and the other outputs are called `y.output' and
`y.tab.h'. The purpose of this switch is to imitate Yacc's output
file name conventions. Thus, the following shell script can substitute
for Yacc:
zyacc -y $*
When Zyacc is run, it looks for certain data files (a skeleton file `zyaccskl.c' and an options file `zyacc.opt' (see section Option Sources)) in certain standard directories (the skeleton file must exist, but the option file need not exist). The search list specifying these standard directories is fixed when Zyacc is installed; it can be printed out using Zyacc's `--help' option (see section Zyacc Options).
The search list consists of a list of colon-separated directory names (the
directory names may or may not have terminating slashes) or environment
variables (starting with a `$'). If a directory name starts with a
`$', then the first (only the first) `$' must be repeated. An
empty component in the search list specifies the current directory.
Typically the search list contains the current directory.
Also typically, the environment variable ZYACC_SEARCH_PATH
is present
in the search list -- this causes Zyacc to check if the variable is set in
the environment. If it is, then Zyacc expects it to specify a search list
which it recursively searches.
Typically, the search list compiled into Zyacc looks something like the following:
$ZYACC_SEARCH_PATH:.:$HOME:/usr/local/share/zyacc
Since the search list will typically contain an environment variable like
ZYACC_SEARCH_PATH
it is possible to change the set of standard
directories searched by Zyacc even after installation by specifying a
value for the variable. For example, if with the above search list,
ZYACC_SEARCH_PATH
is set to /usr/lib:/usr/opt/lib
, then
the effective search list becomes:
/usr/lib:/usr/opt/lib:.:$HOME:/usr/local/share/zyacc
Feedback: Please email any feedback to zdu@acm.org.