1 .\"**************************************************************************
2 .\"* *
3 .\"* OCaml *
4 .\"* *
5 .\"* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
6 .\"* *
7 .\"* Copyright 1996 Institut National de Recherche en Informatique et *
8 .\"* en Automatique. *
9 .\"* *
10 .\"* All rights reserved. This file is distributed under the terms of *
11 .\"* the GNU Lesser General Public License version 2.1, with the *
12 .\"* special exception on linking described in the file LICENSE. *
13 .\"* *
14 .\"**************************************************************************
15 .\"
16 .TH OCAMLYACC 1
17
18 .SH NAME
19 ocamlyacc \- The OCaml parser generator
20
21 .SH SYNOPSIS
22 .B ocamlyacc
23 [
24 .BI \-b prefix
25 ] [
26 .B \-q
27 ] [
28 .B \-v
29 ] [
30 .B \-version
31 ] [
32 .B \-vnum
33 ]
34 .I filename.mly
35
36 .SH DESCRIPTION
37
38 The
39 .BR ocamlyacc (1)
40 command produces a parser from a LALR(1) context-free grammar
41 specification with attached semantic actions, in the style of
42 .BR yacc (1).
43 Assuming the input file is
44 .IR grammar \&.mly,
45 running
46 .B ocamlyacc
47 produces OCaml code for a parser in the file
48 .IR grammar \&.ml,
49 and its interface in file
50 .IR grammar \&.mli.
51
52 The generated module defines one parsing function per entry point in
53 the grammar. These functions have the same names as the entry points.
54 Parsing functions take as arguments a lexical analyzer (a function
55 from lexer buffers to tokens) and a lexer buffer, and return the
56 semantic attribute of the corresponding entry point. Lexical analyzer
57 functions are usually generated from a lexer specification by the
58 .BR ocamllex (1)
59 program. Lexer buffers are an abstract data type
60 implemented in the standard library module Lexing. Tokens are values from
61 the concrete type token, defined in the interface file
62 .IR grammar \&.mli
63 produced by
64 .BR ocamlyacc (1).
65
66 .SH OPTIONS
67
68 The
69 .BR ocamlyacc (1)
70 command recognizes the following options:
71 .TP
72 .BI \-b prefix
73 Name the output files
74 .IR prefix \&.ml,
75 .IR prefix \&.mli,
76 .IR prefix \&.output,
77 instead of the default naming convention.
78 .TP
79 .B \-q
80 This option has no effect.
81 .TP
82 .B \--strict
83 Reject grammars with conflicts.
84 .TP
85 .B \-v
86 Generate a description of the parsing tables and a report on conflicts
87 resulting from ambiguities in the grammar. The description is put in
88 file
89 .IR grammar .output.
90 .TP
91 .B \-version
92 Print version string and exit.
93 .TP
94 .B \-vnum
95 Print short version number and exit.
96 .TP
97 .B \-
98 Read the grammar specification from standard input. The default
99 output file names are stdin.ml and stdin.mli.
100 .TP
101 .BI \-\- \ file
102 Process
103 .I file
104 as the grammar specification, even if its name
105 starts with a dash (-) character. This option must be the last on the
106 command line.
107
108 .SH SEE ALSO
109 .BR ocamllex (1).
110 .br
111 .IR "The OCaml user's manual" ,
112 chapter "Lexer and parser generators".
113