summaryrefslogtreecommitdiff
path: root/man/ocamlyacc.m
blob: f522d5cc268c88ab84608babbc57d71a9633227c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.\"**************************************************************************
.\"*                                                                        *
.\"*                                 OCaml                                  *
.\"*                                                                        *
.\"*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *
.\"*                                                                        *
.\"*   Copyright 1996 Institut National de Recherche en Informatique et     *
.\"*     en Automatique.                                                    *
.\"*                                                                        *
.\"*   All rights reserved.  This file is distributed under the terms of    *
.\"*   the GNU Lesser General Public License version 2.1, with the          *
.\"*   special exception on linking described in the file LICENSE.          *
.\"*                                                                        *
.\"**************************************************************************
.\"
.TH OCAMLYACC 1

.SH NAME
ocamlyacc \- The OCaml parser generator

.SH SYNOPSIS
.B ocamlyacc
[
.BI \-b prefix
] [
.B \-q
] [
.B \-v
] [
.B \-version
] [
.B \-vnum
]
.I filename.mly

.SH DESCRIPTION

The
.BR ocamlyacc (1)
command produces a parser from a LALR(1) context-free grammar
specification with attached semantic actions, in the style of
.BR yacc (1).
Assuming the input file is
.IR grammar \&.mly,
running
.B ocamlyacc
produces OCaml code for a parser in the file
.IR grammar \&.ml,
and its interface in file
.IR grammar \&.mli.

The generated module defines one parsing function per entry point in
the grammar. These functions have the same names as the entry points.
Parsing functions take as arguments a lexical analyzer (a function
from lexer buffers to tokens) and a lexer buffer, and return the
semantic attribute of the corresponding entry point. Lexical analyzer
functions are usually generated from a lexer specification by the
.BR ocamllex (1)
program. Lexer buffers are an abstract data type
implemented in the standard library module Lexing. Tokens are values from
the concrete type token, defined in the interface file
.IR grammar \&.mli
produced by
.BR ocamlyacc (1).

.SH OPTIONS

The
.BR ocamlyacc (1)
command recognizes the following options:
.TP
.BI \-b prefix
Name the output files
.IR prefix \&.ml,
.IR prefix \&.mli,
.IR prefix \&.output,
instead of the default naming convention.
.TP
.B \-q
This option has no effect.
.TP
.B \--strict
Reject grammars with conflicts.
.TP
.B \-v
Generate a description of the parsing tables and a report on conflicts
resulting from ambiguities in the grammar. The description is put in
file
.IR grammar .output.
.TP
.B \-version
Print version string and exit.
.TP
.B \-vnum
Print short version number and exit.
.TP
.B \-
Read the grammar specification from standard input.  The default
output file names are stdin.ml and stdin.mli.
.TP
.BI \-\- \ file
Process
.I file
as the grammar specification, even if its name
starts with a dash (-) character.  This option must be the last on the
command line.

.SH SEE ALSO
.BR ocamllex (1).
.br
.IR "The OCaml user's manual" ,
chapter "Lexer and parser generators".