fatbase

portable OpenBSD tools
git clone git://git.2f30.org/fatbase
Log | Files | Refs

yacc.1 (6150B)


      1 .\"	$OpenBSD: yacc.1,v 1.30 2014/06/04 06:55:50 jmc Exp $
      2 .\"
      3 .\" Copyright (c) 1989, 1990 The Regents of the University of California.
      4 .\" All rights reserved.
      5 .\"
      6 .\" This code is derived from software contributed to Berkeley by
      7 .\" Robert Paul Corbett.
      8 .\"
      9 .\" Redistribution and use in source and binary forms, with or without
     10 .\" modification, are permitted provided that the following conditions
     11 .\" are met:
     12 .\" 1. Redistributions of source code must retain the above copyright
     13 .\"    notice, this list of conditions and the following disclaimer.
     14 .\" 2. Redistributions in binary form must reproduce the above copyright
     15 .\"    notice, this list of conditions and the following disclaimer in the
     16 .\"    documentation and/or other materials provided with the distribution.
     17 .\" 3. Neither the name of the University nor the names of its contributors
     18 .\"    may be used to endorse or promote products derived from this software
     19 .\"    without specific prior written permission.
     20 .\"
     21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31 .\" SUCH DAMAGE.
     32 .\"
     33 .\"	from: @(#)yacc.1	5.7 (Berkeley) 7/30/91
     34 .\"
     35 .Dd $Mdocdate: June 4 2014 $
     36 .Dt YACC 1
     37 .Os
     38 .Sh NAME
     39 .Nm yacc
     40 .Nd an
     41 .Tn LALR(1)
     42 parser generator
     43 .Sh SYNOPSIS
     44 .Nm yacc
     45 .Op Fl dlrtv
     46 .Op Fl b Ar file_prefix
     47 .Op Fl o Ar output_file
     48 .Op Fl p Ar symbol_prefix
     49 .Ar file
     50 .Sh DESCRIPTION
     51 .Nm
     52 reads the grammar specification in
     53 .Ar file
     54 and generates an
     55 .Tn LR(1)
     56 parser for it.
     57 The parsers consist of a set of
     58 .Tn LALR(1)
     59 parsing tables and a driver routine
     60 written in the C programming language.
     61 .Nm
     62 normally writes the parse tables and the driver routine to the file
     63 .Pa y.tab.c .
     64 .Pp
     65 The options are as follows:
     66 .Bl -tag -width Ds
     67 .It Fl b Ar file_prefix
     68 The
     69 .Fl b
     70 option changes the prefix prepended to the output file names to
     71 the string denoted by
     72 .Ar file_prefix .
     73 The default prefix is the character
     74 .Ar y .
     75 .It Fl d
     76 The
     77 .Fl d
     78 option causes the header file
     79 .Pa y.tab.h
     80 to be written.
     81 .It Fl l
     82 If the
     83 .Fl l
     84 option is not specified,
     85 .Nm
     86 will insert #line directives in the generated code.
     87 The #line directives let the C compiler relate errors in the
     88 generated code to the user's original code.
     89 If the
     90 .Fl l
     91 option is specified,
     92 .Nm
     93 will not insert the #line directives.
     94 #line directives specified by the user will be retained.
     95 .It Fl o Ar output_file
     96 The
     97 .Fl o
     98 option specifies an explicit name for the parser's output file name instead
     99 of the default.
    100 The names of the other output files are constructed from
    101 .Pa output_file
    102 as described under the
    103 .Fl d
    104 and
    105 .Fl v
    106 options.
    107 .It Fl p Ar symbol_prefix
    108 The
    109 .Fl p
    110 option changes the prefix prepended to yacc-generated symbols to
    111 the string denoted by
    112 .Ar symbol_prefix .
    113 The default prefix is the string
    114 .Ar yy .
    115 .It Fl r
    116 The
    117 .Fl r
    118 option causes
    119 .Nm
    120 to produce separate files for code and tables.
    121 The code file is named
    122 .Pa y.code.c ,
    123 and the tables file is named
    124 .Pa y.tab.c .
    125 .It Fl t
    126 The
    127 .Fl t
    128 option changes the preprocessor directives generated by
    129 .Nm
    130 so that debugging statements will be incorporated in the compiled code.
    131 .It Fl v
    132 The
    133 .Fl v
    134 option causes a human-readable description of the generated parser to
    135 be written to the file
    136 .Pa y.output .
    137 .El
    138 .Sh ENVIRONMENT
    139 .Bl -tag -width TMPDIR
    140 .It Ev TMPDIR
    141 Name of directory where temporary files are to be created.
    142 .El
    143 .Sh TABLES
    144 The names of the tables generated by this version of
    145 .Nm
    146 are
    147 .Dq yylhs ,
    148 .Dq yylen ,
    149 .Dq yydefred ,
    150 .Dq yydgoto ,
    151 .Dq yysindex ,
    152 .Dq yyrindex ,
    153 .Dq yygindex ,
    154 .Dq yytable ,
    155 and
    156 .Dq yycheck .
    157 Two additional tables,
    158 .Dq yyname
    159 and
    160 .Dq yyrule ,
    161 are created if
    162 .Dv YYDEBUG
    163 is defined and non-zero.
    164 .Sh FILES
    165 .Bl -tag -width /tmp/yacc.uXXXXXXXXXX -compact
    166 .It Pa y.code.c
    167 .It Pa y.tab.c
    168 .It Pa y.tab.h
    169 .It Pa y.output
    170 .It Pa /tmp/yacc.aXXXXXXXXXX
    171 .It Pa /tmp/yacc.tXXXXXXXXXX
    172 .It Pa /tmp/yacc.uXXXXXXXXXX
    173 .El
    174 .Sh EXIT STATUS
    175 .Ex -std yacc
    176 .Sh DIAGNOSTICS
    177 If there are rules that are never reduced, the number of such rules is
    178 written to the standard error.
    179 If there are any
    180 .Tn LALR(1)
    181 conflicts, the number of conflicts is also written
    182 to the standard error.
    183 .Sh SEE ALSO
    184 .Xr yyfix 1
    185 .Rs
    186 .%A F. DeRemer
    187 .%A T. J. Pennello
    188 .%D 1982
    189 .%J TOPLAS
    190 .%N Issue 4
    191 .%P pp. 615\(en649
    192 .%T Efficient Computation of LALR(1) Look-Ahead Sets
    193 .%V Volume 4
    194 .Re
    195 .Sh STANDARDS
    196 The
    197 .Nm
    198 utility is compliant with the
    199 .St -p1003.1-2008
    200 specification,
    201 though its presence is optional.
    202 .Pp
    203 The flags
    204 .Op Fl or ,
    205 as well as the environment variable
    206 .Ev TMPDIR ,
    207 are extensions to that specification.
    208 .Sh HISTORY
    209 .Nm
    210 was originally developed at AT&T by
    211 .An Stephen C. Johnson .
    212 .Pp
    213 Berkeley
    214 .Nm
    215 was originally developed using PCC on a VAX with the
    216 intent of being as compatible as possible with
    217 .At
    218 .Nm .
    219 Much is owed to the unflagging efforts of Keith Bostic.
    220 His badgering kept me working on
    221 .Nm
    222 long after I was ready to quit.
    223 .Pp
    224 Berkeley
    225 .Nm
    226 is based on the excellent algorithm for computing
    227 LALR(1) lookaheads developed by
    228 .An Tom Pennello
    229 and
    230 .An Frank DeRemer .
    231 The algorithm is described in their almost impenetrable article in
    232 TOPLAS (see above).
    233 .Pp
    234 Finally, much credit must go to those who pointed out deficiencies
    235 of earlier releases.
    236 Among the most prolific contributors were
    237 Benson I. Margulies,
    238 Dave Gentzel,
    239 Antoine Verheijen,
    240 Peter S. Housel,
    241 Dale Smith,
    242 Ozan Yigit,
    243 John Campbell,
    244 Bill Sommerfeld,
    245 Paul Hilfinger,
    246 Gary Bridgewater,
    247 Dave Bakken,
    248 Dan Lanciani,
    249 Richard Sargent,
    250 and
    251 Parag Patel.
    252 .Sh AUTHORS
    253 The
    254 .Nm
    255 utility was written by
    256 .An Robert Corbett .