1YACC(1)                          User Commands                         YACC(1)
2
3
4

NAME

6       Yacc - an LALR(1) parser generator
7

SYNOPSIS

9       yacc [ -dglrtv ] [ -b file_prefix ] [ -p symbol_prefix ] filename
10

DESCRIPTION

12       Yacc reads the grammar specification in the file filename and generates
13       an LALR(1) parser for it.  The parsers consist  of  a  set  of  LALR(1)
14       parsing  tables  and a driver routine written in the C programming lan‐
15       guage.  Yacc normally writes the parse tables and the driver routine to
16       the file y.tab.c.
17
18       The following options are available:
19
20       -b file_prefix
21              The  -b  option  changes the prefix prepended to the output file
22              names to the string denoted by file_prefix.  The default  prefix
23              is the character y.
24
25       -d     The -d option causes the header file y.tab.h to be written.
26
27       -g     The  -g  option  causes a graphical description of the generated
28              LALR(1) parser to be written to the file y.dot in graphviz  for‐
29              mat, ready to be processed by dot(1).
30
31       -l     If the -l option is not specified, yacc will insert #line direc‐
32              tives in the generated code.  The #line  directives  let  the  C
33              compiler relate errors in the generated code to the user's orig‐
34              inal code.  If the -l option is specified, yacc will not  insert
35              the  #line  directives.   #line directives specified by the user
36              will be retained.
37
38       -o output_file
39              specify the filename for the parser file.  If this option is not
40              given,  the output filename is the file prefix concatenated with
41              the file suffix, e.g., y.tab.c.  This overrides the -p option.
42
43       -p symbol_prefix
44              The -p option changes the  prefix  prepended  to  yacc-generated
45              symbols  to  the  string  denoted by symbol_prefix.  The default
46              prefix is the string yy.
47
48       -P     create a reentrant parser, e.g., "%pure-parser".
49
50       -r     The -r option causes yacc to produce separate files for code and
51              tables.  The code file is named y.code.c, and the tables file is
52              named y.tab.c.
53
54       -t     The -t option changes the preprocessor directives  generated  by
55              yacc  so  that  debugging statements will be incorporated in the
56              compiled code.
57
58       -v     The -v option causes a human-readable description of the  gener‐
59              ated parser to be written to the file y.output.
60
61       -V     print the version number to the standard output.
62

EXTENSIONS

64       yacc  provides  some  extensions for compatibility with bison and other
65       implementations of yacc:
66
67        %expect number
68              tell yacc the expected number of shift/reduce  conflicts.   That
69              makes it only report the number if it differs.
70
71        %expect-rr number
72              tell  yacc the expected number of reduce/reduce conflicts.  That
73              makes it only report the number if it differs.  This is  (unlike
74              bison) allowable in LALR parsers.
75
76        %pure-parser
77              Most variables (other than yydebug and yynerrs) are allocated on
78              the stack within yyparse, making  the  parser  reasonably  reen‐
79              trant.
80

DIAGNOSTICS

82       If  there are rules that are never reduced, the number of such rules is
83       reported on standard error.  If there are any  LALR(1)  conflicts,  the
84       number of conflicts is reported on standard error.
85
86
87
88Berkeley Yacc                  February 16, 2010                       YACC(1)
Impressum