Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2002-01-13 (13:48)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] camlp4: LIST1 construct on record patterns

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)

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

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/

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

Bug reports:  FAQ:
To unsubscribe, mail  Archives: