English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Hacking the lexer in the new camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-29 (15:29)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] Hacking the lexer in the new camlp4
On 3/29/07, Harrison, John R <john.r.harrison@intel.com> wrote:
> | > In the current camlp4, the only way I found to do this was basically
> | > to copy the existing lexer and edit it. Although it works, it's ugly
> | > and invariably means that I've had to change something with almost
> | > every new version of camlp4. Does the new camlp4 offer a nicer way
> of
> | > changing the lexer?
> |
> | How did you that in the previous one without copy/paste the old lexer?
> Indeed, that's exactly what I did in the old camlp4. But I am curious if
> the new camlp4 offers, or could offer, a more modular solution.

Ok, so the new one is build with ocamllex, so it's not really extensible.

If you want to accept something that is currently rejected by the
lexer you need to change it.
However if it's just a matter of patching the token stream you can do
it more easily by adding a token filter (Camlp4.Sig.Token.Filter).

Nicolas Pouillard