Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] (Release) ocamllex tutorial (ver 0.1)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] (Release) ocamllex tutorial (ver 0.1)
On Tue, 2004-08-24 at 18:07, SooHyoung Oh wrote:

> Any comment will be appreciated.

It looks very good!

> This tutorial is work-in-progress. The latest version can be found at

First -- you haven't explained how to use the new argument
feature. A good example would be to take the non-reentrant
line counting example and show how to make it re-entrant
by passing an object containing the counters.

To justify not using a global variable, you can extend
the example to allow for recursively counting #include
files (or something similar :)

The second thing I'd like to see here is an example
showing the common technique of lexing an identifier
and then using a lookup table to see if it is keyword:
this is done because (a) it is possible and (b) it
simplifies the lexer which otherwise needs a huge
number of states.

The third thing I'd like to see is a more functional example
where the lexer isn't just executing code for side effects.
All your examples have the lexer tail calling itself: but
most real lexing applications do not do this, instead
you call the lexer repeatedly from a driver loop.

In particular Ocamlyacc calls Ocamllex to lex one
token at a time.

Finally -- since your tutorial is Ocaml specific,
I'd like to see some information on lexbufs.
Are they functional? Can I write a backtracking
functional parser that just 'goes backwards'
in the input stream using a lexbuf to allow
re-lexing some input? 

How do i cope with the fact
that lexbufs think they're reading named
files with lines in them .. what if this isn't so?

This is actually a design fault which is unfortunately
propagated to Ocamlyacc.

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: