The output of ocamllex is the file lex.ml when it is invoked as ocamllex lex.mll
. The generated file contains the scanning functions, a number of tables used by it for matching tokens, and a number of auxiliary routines.
The scanning functions are declared as followings:
let <entrypoint> [arg1... argn] lexbuf =
...
and ...
where the fuction entrypoint has n + 1
arguments.
n
arguments come from the definition of the rules secton.
And the resulting scanning function has one more argument named lexbuf of Lexing.lexbuf type as the last one.
Whenever entrypoint is called, it scans tokens from the lexbuf argument. When it finds a match in patterns, it executes the corresponding action and returns. If you want to continue the lexical analyze after evaluating of the action, you must call the scanning function recursively.