CAMLLEX(1)

NAME
camllex - a lexical analyzer generator for Caml Light

SYNOPSIS
camllex lexer.mll

DESCRIPTION
camllex produces a lexical analyzer from a set of regular expressions with attached semantic actions, in the style of lex(1). Assuming the input file is lexer.mll, camllex produces the file lexer.ml. The output file must be compiled by Caml Light, and linked with the rest of the program. The generated module defines one lexing function per entry points in the lexer definition. These functions have the same names as the entry points. Lexing functions take as argument a lexer buffer, and return the semantic attribute of the corresponding entry point. Lexer buffers are an abstract data type implemented in the standard library "lexing". When used in conjunction with a parser generated by camlyacc(1), the semantic actions compute a value belonging to the type "token" defined by the generated parsing module.

SEE ALSO
camlyacc(1).
The Caml Light user's manual,

chapter "Lexer and parser generators".
LEX - Lexical Analyzer Generator,

by M. E. Lesk and E. Schmidt.
Compilers - Principles, Techniques, and Tools

(chapter 3), by A. V. Aho, R. Sethi, and J. D. Ullman.

BUGS
Type checking is performed when compiling the .ml output file, not when compiling the lexer definition. This does not break type safety, since the .ml output file is well-typed iff the lexer definition is well-typed. However, this results in type error messages that are somehow hard to relate to the lexer definition.