ocamllex

(ocamllex <names>) is essentially a shorthand for:

(rule
 (target <name>.ml)
 (deps   <name>.mll)
 (action (chdir %{workspace_root}
          (run %{bin:ocamllex} -q -o %{target} %{deps}))))

To use a different rule mode, use the long form:

(ocamllex
 (modules <names>)
 (mode    <mode>))

Starting in Dune 3.25, the flags field passes additional command-line arguments to ocamllex. The flags use the Ordered Set Language and support Variables. For example, -ml generates an OCaml-based automaton instead of using the built-in automata interpreter:

(ocamllex
 (modules lexer)
 (flags -ml))