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