Module Future.Genlex


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 string
| Ident of string
| Int of int
| Float of float
| String of string
| Char of char
type t 
A lexer
val of_list : string list -> t
Create a lexer from a list of keywords
val to_stream_filter : t ->
char Stream.t -> token Stream.t
Apply the lexer to a stream.
val to_enum_filter : t ->
char Enum.t -> token Enum.t
Apply the lexer to an enum.
val to_lazy_list_filter : t ->
char Lazy_list.t -> token Lazy_list.t
Apply the lexer to a lazy list.
val make_lexer : string list -> char Stream.t -> token Stream.t
Old functions

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.


Extending to other languages

module Future.Genlex.Languages: sig .. end