module Future.Genlex: Extlib.ExtGenlex.Genlex
A generic lexical analyzer.
This module implements a simple ``standard'' lexical analyzer, presented
as a function from character streams to token streams. It implements
roughly the lexical conventions of Caml, but is parameterized by the
set of keywords of your language.
Author(s): Jacques Garrigue, David Teller
type
token =
| |
Kwd of |
| |
Ident of |
| |
Int of |
| |
Float of |
| |
String of |
| |
Char of |
type
t
val of_list : string list -> t
val to_stream_filter : t ->
char Stream.t -> token Stream.t
val to_enum_filter : t ->
char Enum.t -> token Enum.t
val to_lazy_list_filter : t ->
char Lazy_list.t -> token Lazy_list.t
val make_lexer : string list -> char Stream.t -> token Stream.t
Construct the lexer function. The first argument is the list of
keywords. An identifier s is returned as Kwd s if s belongs to this
list, and as Ident s otherwise. A special character s is returned
as Kwd s if s belongs to this list, and cause a lexical error
(exception Parse_error) otherwise. Blanks and newlines are
skipped. Comments delimited by (* and *) are skipped as well, and
can be nested.
module Future.Genlex.Languages:sig
..end