| 1 |
= MLLex |
| 2 |
|
| 3 |
<<MLLex#>> is a lexical analyzer generator for <<StandardML#,Standard ML>> |
| 4 |
modeled after the Lex lexical analyzer generator. |
| 5 |
|
| 6 |
A version of MLLex, ported from the <<SMLNJ#,SML/NJ>> sources, is |
| 7 |
distributed with MLton. |
| 8 |
|
| 9 |
== Description |
| 10 |
|
| 11 |
MLLex takes as input the lex language as defined in the ML-Lex manual, |
| 12 |
and outputs a lexical analyzer in SML. |
| 13 |
|
| 14 |
== Implementation |
| 15 |
|
| 16 |
* https://github.com/MLton/mlton/blob/master/mllex/lexgen.sml[`lexgen.sml`] |
| 17 |
* https://github.com/MLton/mlton/blob/master/mllex/main.sml[`main.sml`] |
| 18 |
* https://github.com/MLton/mlton/blob/master/mllex/call-main.sml[`call-main.sml`] |
| 19 |
|
| 20 |
== Details and Notes |
| 21 |
|
| 22 |
There are 3 main passes in the MLLex tool: |
| 23 |
|
| 24 |
* 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.) |
| 25 |
* DFA construction. In this pass, a DFA is constructed by the algorithm of H. Yamada et. al. |
| 26 |
* Output. In this pass, the generated DFA is written out as a transition table, along with a table-driven algorithm, to an SML file. |
| 27 |
|
| 28 |
== Also see |
| 29 |
|
| 30 |
* link:Documentation.attachments/mllex.pdf[`mllex.pdf`] |
| 31 |
* <<MLYacc#>> |
| 32 |
* <<References#AppelEtAl94,AppelEtAl94>> |
| 33 |
* <<References#Price09,Price09>> |