Version française
Home     About     Download     Resources     Contact us    
Browse thread
camlp4 stream parser syntax
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Matthieu Wipliez <mwipliez@y...>
Subject: Re : [Caml-list] Re: camlp4 stream parser syntax

> > So to sum up: when you declare a rule with a token "MyToken", the grammar is 
> configured to recognize a "MyToken" keyword.
> 
> The issue here is that it must be lower case in the camlp4 rules, i.e. 
> "mytoken".

Why "it must"? You need it to be lower-case? Or parsing does not work if it is not lower-case?

Maybe I did not understand correctly what you want...
I thought you wanted to recognize
  BuyOrSell something
  buyORsell something

using a single rule, say
  buy : [ [ "buyOrSell"; ... ] ]

If that is the case, I think my solution works.
You might even do that:
  buy : [ [ "buy_or_sell"; ... ] ]

and at lexing time do
  if String.lowercase s = "buyorsell" then
    IDENT "buy_or_sell"
  else
    IDENT s

In this case it is more than a matter of case, but the argument is still valid: I have declared a rule with "buy_or_sell", so the rule will be taken when a "buy_or_sell" keyword is found, and the lexer produces "buy_or_sell" identifiers from anything that matches case-insensitively "BuyOrSell".

Cheers,
Matthieu