From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA26787; Sun, 13 Jan 2002 14:48:24 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA27362 for ; Sun, 13 Jan 2002 14:48:23 +0100 (MET) Received: from verdot.inria.fr (verdot.inria.fr [128.93.11.7]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g0DDmNP01352 for ; Sun, 13 Jan 2002 14:48:23 +0100 (MET) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id OAA24565 for caml-list@inria.fr; Sun, 13 Jan 2002 14:48:23 +0100 Date: Sun, 13 Jan 2002 14:48:23 +0100 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re: [Caml-list] camlp4: LIST1 construct on record patterns Message-ID: <20020113144823.E24240@verdot.inria.fr> References: <005401c19bf4$93d638a0$0b01a8c0@mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <005401c19bf4$93d638a0$0b01a8c0@mit.edu>; from jehenrik@yahoo.com on Sun, Jan 13, 2002 at 12:38:49AM -0500 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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