MLLex is a lexical analyzer generator for Standard ML modeled after the Lex lexical analyzer generator.

A version of MLLex, ported from the SML/NJ sources, is distributed with MLton.


MLLex takes as input the lex language as defined in the ML-Lex manual, and outputs a lexical analyzer in SML.


Details and Notes

There are 3 main passes in the MLLex tool:

  • Source parsing. In this pass, lex source program are parsed into internal representations. The core part of this pass is a hand-written lexer and an LL(1) parser. The output of this pass is a record of user code, rules (along with start states) and actions. (MLLex definitions are wiped off.)

  • DFA construction. In this pass, a DFA is constructed by the algorithm of H. Yamada et. al.

  • Output. In this pass, the generated DFA is written out as a transition table, along with a table-driven algorithm, to an SML file.

Also see