smllex1
The lexical analyzer generator for sml#
Usage
smllex [-o
file]
filename ...
Overview
SMLLex is a lexical analyzer generator in the style of ML-Lex. It accepts input files designed for ML-Lex. Generated programs can be compiled by the SML# compiler. They are compatible to those of ML-Lex with a few exceptions.
When multiple input files are given, each input file is separately read and yields a separate program. By default, the output file name is obtained by appending .sml suffix to the input file name.
To compile the generated program with SML#, an interface file (.smi file) is needed. See EXAMPLES for details.
Options
-
-o filename -
Set the output file name of the first input.
Examples
The following is a minimal example of an input file ex.lex:
type lexresult = bool optionfun eof () = NONE%%%structure ExampleLex%%"T" => (SOME true);"F" => (SOME false);
By applying this file to smllex,
smllex ex.lex
you obtains a program named ex.lex.sml. To compile it, you need to create the following ex.lex.smi file by yourself:
_require "basis.smi"structure ExampleLex =structexception LexErrorval makeLexer : (int -> string) -> unit -> bool optionend
When your .lex file has an %arg, directive, for example,
type lexresult = bool optionfun eof {inverse} = NONE%%%structure Example2Lex%arg ({inverse});%%"T" => (SOME (if inverse then false else true));"F" => (SOME (if inverse then true else false));
the generated makeLexer function takes an additional argument:
_require "basis.smi"structure Example2Lex =structexception LexErrorval makeLexer : (int -> string) -> {inverse : bool}-> unit -> bool optionend