On Sun, 2005-07-31 at 23:21 +1000, Pietro Abate wrote: > Hi all, > > I'm trying to write a generic parser similar to the buidlExpressionParser > in the haskel library (without using external libraries). I came up with > a kind of hack that uses the grammar extension mechanism (attached). > > Is there a better way of doing this ? Do I understand right: you're leveraging the camlp4 library code to build a general purpose LL(1) parser which will support runtime extension? > Does anybody have an example on how to write a simple lexer that I can > use instead ? Hmmm ... don't know about 'simple lexer' but I have a library function that can translate a representation of a labelled sequence of regexps into a tokeniser. I would not call this system 'simple' but it is entirely combinator based, and generates a lex style deterministic finite state automaton. You may want an NFA based interpreter instead though. -- John Skaller