Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] camlp4: LIST1 construct on record patterns
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] camlp4: LIST1 construct on record patterns
Hi,

On Sun, Jan 13, 2002 at 12:38:49AM -0500, Jeff Henrikson wrote:

>       [ [ $cons$; "{"; memb = LIST1 reenter SEP ";" ; "}" ->
>             <:expr<{$list:memb$}>> ] ]
>                           ^^^^
> This expression has type Obj.t list but is here used with type
>   (MLast.patt * MLast.expr) list

The problem is that Grammar.Entry.find cannot answer the right entry
type, since it can be any type. It is like "input_value". This is a
problem indeed to search for hidden entries. You have to know its real
type and magicify it (sorry):

  let lbl_expr_list =
    (Obj.magic (Grammar.Entry.find expr "lbl_expr_list") :
       (MLast.patt * MLast.expr) list Grammar.Entry.e)
  in
  ...

Something like that, I have not checked...

Yes, it is a little bit dirty, but I cannot export all the small
entries of the grammar.

> which doesn't tell me the meaning of test_label_eq

The entry "test_label_eq" is a hack to allow to separate the rules:
    { lbl_expr_list }
    { expr with lbl_expr_list }

The system of grammar of Camlp4 is not strong enough to separate
"lbl_expr_list" and "expr" which can start with the same tokens (it is
LL(infinity), because the first label can be A.B.C.D...lab). In
revised syntax, to avoid that problem, the "expr" must be
parenthesised.

There is some other hacks like that in the normal syntax.

The entry "test_label_eq" is written with a parser; it is created with
Grammar.Entry.of_parser and is not extensible and not visible by
Grammar.Entry.print. See the sources: camlp4/etc/pa_o.ml.

Sorry, Luke, you entered the dark side of Camlp4... :-)

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr