= MLLex

<<MLLex#>> is a lexical analyzer generator for <<StandardML#,Standard ML>>
modeled after the Lex lexical analyzer generator.

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

== Description

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

== Implementation

* https://github.com/MLton/mlton/blob/master/mllex/lexgen.sml[`lexgen.sml`]
* https://github.com/MLton/mlton/blob/master/mllex/main.sml[`main.sml`]
* https://github.com/MLton/mlton/blob/master/mllex/call-main.sml[`call-main.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

* link:Documentation.attachments/mllex.pdf[`mllex.pdf`]
* <<MLYacc#>>
* <<References#AppelEtAl94,AppelEtAl94>>
* <<References#Price09,Price09>>
