Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

plan9-yacc(1) [debian man page]

YACC(1) 						      General Commands Manual							   YACC(1)

NAME
yacc - yet another compiler-compiler SYNOPSIS
yacc [ option ... ] grammar DESCRIPTION
Yacc converts a context-free grammar and translation code into a set of tables for an LR(1) parser and translator. The grammar may be ambiguous; specified precedence rules are used to break ambiguities. The output file, y.tab.c, must be compiled by the C compiler to produce a program This program must be loaded with a lexical analyzer func- tion, yylex(void) (often generated by lex(1)), with a main(int argc, char *argv[]) program, and with an error handling routine, yyer- ror(char*). The options are -o output Direct output to the specified file instead of y.tab.c. -Dn Create file y.debug, containing diagnostic messages. To incorporate them in the parser, compile it with preprocessor symbol yydebug defined. The amount of diagnostic output from the parser is regulated by value n. The value 0 reports errors; 1 reports reductions; higher values (up to 4) include more information about state transitions. -v Create file y.output, containing a description of the parsing tables and of conflicts arising from ambiguities in the grammar. -d Create file y.tab.h, containing #define statements that associate yacc-assigned `token codes' with user-declared `token names'. Include it in source files other than y.tab.c to give access to the token codes. -s stem Change the prefix of the file names y.tab.c, y.tab.h, y.debug, and y.output to stem. -S Write a parser that uses Stdio instead of the print routines in libc. -l Disable #line directives in the generated parser. -a Generate a parser that takes an argument of type Yyarg and passes this argument to each invocation of the lexer function, yylex. Yyarg contains per-instance state and a single user-visible member, arg, of type void*. The specification of yacc itself is essentially the same as the UNIX version described in the references mentioned below. Besides the -D option, the main relevant differences are: The interface to the C environment is by default through <libc.h> rather than <stdio.h>; the -S option reverses this. The parser accepts UTF input text (see utf(7)), which has a couple of effects. First, the return value of yylex() no longer fits in a short; second, the starting value for non-terminals is now 0xE000 rather than 257. The generated parser can be recursive: actions can call yyparse, for example to implement a sort of #include statement in an inter- preter. Finally, some undocumented inner workings of the parser have been changed, which may affect programs that know too much about its structure. FILES
y.output y.tab.c y.tab.h y.debug y.tmp.* temporary file y.acts.* temporary file /lib/yaccpar parser prototype /lib/yaccpars parser prototype using stdio SOURCE
/src/cmd/yacc.c SEE ALSO
lex(1) S. C. Johnson and R. Sethi, ``Yacc: A parser generator'', Unix Research System Programmer's Manual, Tenth Edition, Volume 2 B. W. Kernighan and Rob Pike, The UNIX Programming Environment, Prentice Hall, 1984 BUGS
The parser may not have full information when it writes to y.debug so that the names of the tokens returned by may be missing. YACC(1)

Check Out this Related Man Page

YACC(1) 						    BSD General Commands Manual 						   YACC(1)

NAME
yacc -- an LALR(1) parser generator SYNOPSIS
yacc [-dlrtv] [-b file_prefix] [-o output_filename] [-p symbol_prefix] filename DESCRIPTION
Yacc reads the grammar specification in the file filename and generates an LR(1) parser for it. The parsers consist of a set of LALR(1) parsing tables and a driver routine written in the C programming language. Yacc normally writes the parse tables and the driver routine to the file y.tab.c. The following options are available: -b file_prefix Change the prefix prepended to the output file names to the string denoted by file_prefix. The default prefix is the character y. -d Cause the header file y.tab.h to be written. -l If the -l option is not specified, yacc will insert #line directives in the generated code. The #line directives let the C compiler relate errors in the generated code to the user's original code. If the -l option is specified, yacc will not insert the #line directives. Any #line directives specified by the user will be retained. -o output_filename Cause yacc to write the generated code to output_filename instead of the default file, y.tab.c. -p symbol_prefix Change the prefix prepended to yacc-generated symbols to the string denoted by symbol_prefix. The default prefix is the string yy. -r Cause yacc to produce separate files for code and tables. The code file is named y.code.c, and the tables file is named y.tab.c. -t Change the preprocessor directives generated by yacc so that debugging statements will be incorporated in the compiled code. -v Cause a human-readable description of the generated parser to be written to the file y.output. If the environment variable TMPDIR is set, the string denoted by TMPDIR will be used as the name of the directory where the temporary files are created. FILES
y.code.c y.tab.c y.tab.h y.output /tmp/yacc.aXXXXXXXXXX /tmp/yacc.tXXXXXXXXXX /tmp/yacc.uXXXXXXXXXX DIAGNOSTICS
If there are rules that are never reduced, the number of such rules is reported on standard error. If there are any LALR(1) conflicts, the number of conflicts is reported on standard error. BSD
May 24, 1993 BSD
Man Page