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] camlp4 extensions and lexer replacements
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Goerzen <jgoerzen@c...>
Subject: [Caml-list] camlp4 extensions and lexer replacements

I am working on developing a syntax extension that:

 1. Can use most of the rules in pa_o/pa_r, replaces some, and adds some

 2. Requires a new lexer.

Now, it's easy enough to just accomplish #1 with the EXTEND syntax.  I
can just place my .cmo after pa_o.cmo on the camlp4 command line and
that's good.

But #2 is trickier. contains this:

  Grammar.Unsafe.gram_reinit gram (Plexer.gmake ());

So I can't define my lexer first -- will just overwrite it.
Worse, I can't define my lexer second, either.  Plexer relies on the
(strange, imho) notion of deciding whether something is a LIDENT or
keyword based on the list of keywords-as-tokens that were encountered in
a grammar.  But the grammar reinit functions that I would have to use to
put in my lexer don't preserve that information, so my lexer would have
no way to differentiate a LIDENT from a keyword.  Also, Plexer provides
no way to get a list of entries in its internal hashtable.

It seems that there should be an easy way to do this, but I just can't
figure it out.

I would really avoid having to hack up


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