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 : Re : [Caml-list] Re: camlp4 stream parser syntax

> Matthieu,
> 
> 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.

> Also, I noticed that your lexer has a really small token set, i.e.
> 
> type token =
>     | KEYWORD of string
>     | SYMBOL  of string
>     | IDENT   of string
>     | INT     of int * string
>     | FLOAT   of float * string
>     | CHAR    of char * string
>     | STRING  of string * string
>     | EOI
> 
> My custom lexer, on the other hand, has a HUGE token set, e.g.
> 
>   type token =
>     | BUY_TO_COVER
>     | SELL_SHORT
>     | AT_ENTRY
>     | RANGE
>     | YELLOW
>     | WHITE
>     | WHILE
>     | UNTIL
>     ...
> 
> This is partly because I have a very large set of keywords.
> 
> Do I correctly understand that I do not need all the keywords since I can match 
> them in the camlp4 grammar as strings like "BuyToCover", "SellShort", etc.?

Yes that's right.

Also a good source of information, being given the status of Camlp4
documentation, is Camlp4 source code, especially camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml and
Camlp4OCamlParser.ml

> I had no idea Camlp4 had been used to write such non-trivial parsers...

Actually the aforementioned files show the power of Camlp4 parsing and grammar extension capabilities quite well IMHO.

Cheers,
Matthieu