Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

yacc - yet another compiler-compiler

&pagelevel(4)&pagelevel

The command yacc (yet another compiler-compiler) converts decontextualized grammar into a set of tables for a simple automaton, which runs an LALR(1) syntax analysis algorithm. The grammar may be ambiguous. Certain rules are applied to resolve these ambiguities.

The C compiler must compile the output file y.tab.c (or file_prefix.tab.c, if option -b was specified) in order to create a program yyparse. This program must be linked to a lexical analysis program yylex as well as to main and yyerror, an error handling routine. These routines must be provided by the user. The command lex is used to create lexical analyzers which can be used by yacc.


Syntax


yacc [ -dltv][ -b file_prefix][ -p sym_prefix]| -y driver_file][ -V][ -Q[y|n]][ file ...]

You may specify the following options when calling yacc:

-d

Generates the file y.tab.h with the #define statements which associate the token codes assigned by yacc with the token names allocated by the user. This means that source files other than y.tab.c can access the token codes.

-l

Specifies that the code generated in y.tab.c (or file_prefix.tab.c, if option -b was specified) contains no #line statements. Use this option only if the grammar and associated actions have been fully tested and are error-free.

-t

By default this option compiles code to support runtime error detection. Although the error detection code is always generated in y.tab.c (or file_prefix.tab.c, if option -b was specified), it is subject to conditional compiler control. By default, this is not included when y.tab.c is compiled. Irrespective of whether or not the option -t is set, provision of the code for runtime error detection is controlled by the preprocessor symbol YYDEBUG. If YYDEBUG has a value other than zero the error detection code is linked. If the value is zero, the code is not linked. Programs created without error detection code are smaller and execute more quickly than programs with error detection code.

-v

Prepares the y.output (or file_prefix.output, if option -b was specified) file. This contains a description of the syntax analysis tables and a message about conflicts which have resulted from ambiguities in the grammar.

-b file_prefix

The output files begin with the prefix file_prefix instead of y. The other files required by yacc, such as y.tab.c, y.tab.h and y.output are then also assigned the file names file_prefix.tab.c, file_prefix.tab.h and file_prefix.output.

-p sym_prefix

All external names generated by yacc start with the name sym_prefix instead of yy. This also applies to the functions yyparse(), yylex() and yyerror() and the variables yylval, yychar and yydebug. Internal names may also be affected by the option -p. However, the -p option does not affect #define symbols which are generated by yacc.

-Q[y/n]

Defines whether version information concerning the generated yacc version is to be written to y.tab.c (or file_prefix.tab.c, if option -b was specified) (y) or not (n).

y|n stands for a yes/no argument in whatever language environment is set. In an English-language environment you enter -Qy to have version information written to y.tab.c and -Qn to suppress the version information. In a German-language environment, for example, you would use -Qj or -Qn (for ja or nein).

By default, no version information is output.

-V

Prints the version information for yacc to the standard error output.

-y driver_file

Defines a personal yaccpar file.

File

y.output, y.tab.c
y.tab.h

Definitions of token names
(file_prefix. is used instead of y. if option -b was specified)

yacc.tmp, yacc.debug, yacc.acts

Temporary files

/usr/lib/yaccpar

Analysis algorithm prototype for C programs

/usr/ccs/lib/liby.a

for linking the required modules

Exit status

The number of reduce/reduce and read/reduce conflicts is reported at the standard error output; a detailed report can be found in the y.output (or file_prefix.output, if option -b was specified) file. A message is also output if certain rules cannot be accessed from the start symbol.

Hint

As the file names are usually determined by default (i.e. option -b is not specified), no more than one yacc process can be active at any one time in a given directory.

If c89 [5] is used to link a yacc program, -ly must be specified as the library parameter.

Locale

The following environment variables affect the execution of yacc:

LANG

Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL

If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE

Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other.

LC_MESSAGES

Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

NLSPATH

Determine the location of message catalogs for the processing of LC_MESSAGES.

See also

lex