1
2OCAMLLEX(1) General Commands Manual OCAMLLEX(1)
3
4
5
7 ocamllex - The Objective Caml lexer generator
8
9
11 ocamllex [ -o output-file ] [ -ml ] filename.mll
12
13
15 The ocamllex(1) command generates Objective Caml lexers from a set of
16 regular expressions with associated semantic actions, in the style of
17 lex(1).
18
19 Running ocamllex(1) on the input file lexer.mll produces Caml code for
20 a lexical analyzer in file lexer.ml.
21
22 This file defines one lexing function per entry point in the lexer def‐
23 inition. These functions have the same names as the entry points. Lex‐
24 ing functions take as argument a lexer buffer, and return the semantic
25 attribute of the corresponding entry point.
26
27 Lexer buffers are an abstract data type implemented in the standard
28 library module Lexing. The functions Lexing.from_channel, Lex‐
29 ing.from_string and Lexing.from_function create lexer buffers that read
30 from an input channel, a character string, or any reading function,
31 respectively.
32
33 When used in conjunction with a parser generated by ocamlyacc(1), the
34 semantic actions compute a value belonging to the type token defined by
35 the generated parsing module.
36
37
39 The ocamllex(1) command recognizes the following options:
40
41 -ml Output code that does not use OCaml's built-in automata inter‐
42 preter. Instead, the automaton is encoded by Caml functions.
43 This option is mainly useful for debugging ocamllex(1), using it
44 for production lexers is not recommended.
45
46 -o output-file
47 Specify the name of the output file produced by ocamllex(1).
48 The default is the input file name, with its extension replaced
49 by .ml.
50
51 -q Quiet mode. ocamllex(1) normally outputs informational messages
52 to standard output. They are suppressed if option -q is used.
53
54 -v or -version
55 Print version and exit.
56
57 -help or --help
58 Display a short usage summary and exit.
59
60
62 ocamlyacc(1).
63 The Objective Caml user's manual, chapter "Lexer and parser genera‐
64 tors".
65
66
67
68 OCAMLLEX(1)