Since I don't know how to use the filter either, I tried to find another way :-)

In your lexer, do you have something along the lines of the "calc" examples in 
ocamllex official documentation, like a hash table that associates strings to 
tokens?

In this case, here is a possible solution, you have your hash table associate a 
lowercase version of the token with what you'd like to use in the grammar:
"buytocover" => "BuyToCover"
"sellshort" => "SellShort"
...

And you replace the lookup with
try
  IDENT (Hashtbl.find keyword_table (String.lowercase id))
with Not_found ->
  IDENT id

This way identifiers that when lower-cased look like "buytocover" 
("BuYTOCovEr", "bUytOcOVeR", etc.) are replaced by a single token "BuyToCover", 
against which you match in the grammar.

Could this satisfy your requirements?

Cheers,
Matthieu



----- Message d'origine ----
> De : Joel Reymont <joe...@gmail.com>
> À : Matthieu Wipliez <mwipl...@yahoo.fr>
> Cc : O'Caml Mailing List <caml-list@yquem.inria.fr>
> Envoyé le : Dimanche, 8 Mars 2009, 9h25mn 23s
> Objet : Re: Re : Re : [Caml-list] Re: camlp4 stream parser syntax
> 
> How can I make camlp4 parsing case-insensitive?
> 
> The only approach I can think of so far is to build a really larger  
> set of tokens and use them instead of strings in the parser.
> 
> Any flag I can flip or way to do this without a large set of tokens?
> 
>     Thanks, Joel
> 
> On Mar 8, 2009, at 1:08 AM, Matthieu Wipliez wrote:
> 
> >
> >> Is the camlp4 grammar parser case-insensitive?
> >>
> >> Will both Delay and delay be accepted in the actionDelay rule?
> >>
> >>    actionDelay: [ [ "delay"; expression ->
> >>        Asthelper.failwith (convert_loc _loc)
> >>            "RVC-CAL does not permit the use of delay." ] ];
> >
> > No, only "delay" is accepted.
> 
> 
> 
> ---
> http://tinyco.de
> Mac, C++, OCaml





_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to