1OCAMLYACC(1) General Commands Manual OCAMLYACC(1)
2
3
4
6 ocamlyacc - The Objective Caml parser generator
7
8
10 ocamlyacc [ -v ] [ -bprefix ] filename.mly
11
12
14 The ocamlyacc(1) command produces a parser from a LALR(1) context-free
15 grammar specification with attached semantic actions, in the style of
16 yacc(1). Assuming the input file is grammar.mly, running ocamlyacc
17 produces Caml code for a parser in the file grammar.ml, and its inter‐
18 face in file grammar.mli.
19
20 The generated module defines one parsing function per entry point in
21 the grammar. These functions have the same names as the entry points.
22 Parsing functions take as arguments a lexical analyzer (a function from
23 lexer buffers to tokens) and a lexer buffer, and return the semantic
24 attribute of the corresponding entry point. Lexical analyzer functions
25 are usually generated from a lexer specification by the ocamllex(1)
26 program. Lexer buffers are an abstract data type implemented in the
27 standard library module Lexing. Tokens are values from the concrete
28 type token, defined in the interface file grammar.mli produced by
29 ocamlyacc(1).
30
31
33 The ocamlyacc(1) command recognizes the following options:
34
35
36 -v Generate a description of the parsing tables and a report on
37 conflicts resulting from ambiguities in the grammar. The
38 description is put in file grammar.output.
39
40
41 -bprefix
42 Name the output files prefix.ml, prefix.mli, prefix.output,
43 instead of the default naming convention.
44
45
47 ocamllex(1).
48 The Objective Caml user's manual, chapter "Lexer and parser genera‐
49 tors".
50
51
52
53 OCAMLYACC(1)