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 OCAMLLEX 1
17
18 .SH NAME
19 ocamllex \- The OCaml lexer generator
20
21 .SH SYNOPSIS
22 .B ocamllex
23 [
24 .BI \-o \ output-file
25 ]
26 [
27 .B \-ml
28 ]
29 .I filename.mll
30
31 .SH DESCRIPTION
32
33 The
34 .BR ocamllex (1)
35 command generates OCaml lexers from a set of regular
36 expressions with associated semantic actions, in the style of
37 .BR lex (1).
38
39 Running
40 .BR ocamllex (1)
41 on the input file
42 .IR lexer \&.mll
43 produces OCaml code for a lexical analyzer in file
44 .IR lexer \&.ml.
45
46 This file defines one lexing function per entry point in the lexer
47 definition. These functions have the same names as the entry
48 points. Lexing functions take as argument a lexer buffer, and return
49 the semantic attribute of the corresponding entry point.
50
51 Lexer buffers are an abstract data type implemented in the standard
52 library module Lexing. The functions Lexing.from_channel,
53 Lexing.from_string and Lexing.from_function create
54 lexer buffers that read from an input channel, a character string, or
55 any reading function, respectively.
56
57 When used in conjunction with a parser generated by
58 .BR ocamlyacc (1),
59 the semantic actions compute a value belonging to the type token defined
60 by the generated parsing module.
61
62 .SH OPTIONS
63
64 The
65 .BR ocamllex (1)
66 command recognizes the following options:
67 .TP
68 .B \-ml
69 Output code that does not use OCaml's built-in automata
70 interpreter. Instead, the automaton is encoded by OCaml functions.
71 This option is mainly useful for debugging
72 .BR ocamllex (1),
73 using it for production lexers is not recommended.
74 .TP
75 .BI \-o \ output\-file
76 Specify the name of the output file produced by
77 .BR ocamllex (1).
78 The default is the input file name, with its extension replaced by .ml.
79 .TP
80 .B \-q
81 Quiet mode.
82 .BR ocamllex (1)
83 normally outputs informational messages
84 to standard output. They are suppressed if option
85 .B \-q
86 is used.
87 .TP
88 .BR \-v \ or \ \-version
89 Print version string and exit.
90 .TP
91 .B \-vnum
92 Print short version number and exit.
93 .TP
94 .BR \-help \ or \ \-\-help
95 Display a short usage summary and exit.
96
97 .SH SEE ALSO
98 .BR ocamlyacc (1).
99 .br
100 .IR "The OCaml user's manual" ,
101 chapter "Lexer and parser generators".
102