The Haskell Dynamic Lexer Engine
The Haskell Dynamic Lexer Engine

This library is a simple regular expression lexer/scanner for the Haskell programming language. It is "interesting" because it is completely dynamic: the lexer may be modified at runtime, and string buffers may be lexed by different lexers at different times.

In addition to providing a lexer/scanner package, it also provides access to a regular expression->DFA compiler as well as a package of DFA utilities to modify and run a string through it...

Here are some documents that describe the project:

Okay, now go download the source... there are snapshots of the source available in the snapshot directory.

Example Program [From the Design Document]
Presented here is a simple program that accepts user input consisting of the following keywords: load, help and quit... each of which may be abbreviated with a single letter. The load command is followed by a filename to load. This program is not designed to do meaningful work, just as an example of processing text.

There are several things that complicate processing of user input. The first is the backspace character: because Haskell does not buffer IO, backspaces are sent through as raw input and must be stripped by the application. This is not an insurmountable problem, as it is taken care of with a single function.

The second is the parsing stage of the input. Although they are no substitute for a full-blown parser, Haskell's pattern matching rules are very powerful for handling user input.

The third issue is how to handle errors. This is taken care of with two different techniques: a general error handler and a specific error handler to produce user-friendly error messages. The general technique just uses a pattern matching rule that always matches, and prints the standard "unrecognized input" message. The context specific error handler is used to catch common input errors and gently assist the user.

A user transaction with the program is illustrated below, with user input bolded:

...and here is the source code for the program:

  • Created by Chris Lattner, 2000
  • Last modified on Wednesday, 13-Sep-2000 12:11:03 PDT