From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: *** X-Spam-Status: No, score=3.0 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS,FORGED_YAHOO_RCVD autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id D23E7BC0A for ; Sun, 8 Apr 2007 00:47:54 +0200 (CEST) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l37Mls1g021115 for ; Sun, 8 Apr 2007 00:47:54 +0200 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id A34C8214EF3 for ; Sat, 7 Apr 2007 18:47:54 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Sat, 07 Apr 2007 18:47:53 -0400 X-Sasl-enc: ezARgN9wZORqbu9YQSZW+GRBSn/1NTLXRJW+1QURCHNX 1175986073 Received: from [192.168.0.2] (65-101-133-180.tukw.qwest.net [65.101.133.180]) by mail.messagingengine.com (Postfix) with ESMTP id 31F88178E6 for ; Sat, 7 Apr 2007 18:47:52 -0400 (EDT) Message-ID: <46182064.5030209@yahoo.com> Date: Sat, 07 Apr 2007 15:51:16 -0700 From: Jeff Henrikson User-Agent: Thunderbird 1.5.0.10 (Macintosh/20070221) MIME-Version: 1.0 To: caml-list@inria.fr Subject: compiling camlp4 dynamic_functor_example.ml Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-j-chkmail-Score: MSGID : 46181F9A.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46181F9A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; henrikson:01 jehenrik:01 camlp:01 functor:01 functor:01 camlp:01 foo:01 struct:01 syntax:01 syntax:01 sig:01 struct:01 foo:01 sig:01 lident:01 The "dynamic_functor_example.ml" from the documentation appears to not compile anymore with the latest camlp4 release. Here's my attempt to make it work. from http://gallium.inria.fr/~pouillar/camlp4-changes.html dynamic_functor_example.ml type t1 = A | B type t2 = Foo of string * t1 open Camlp4 module Id = struct (* Information for dynamic loading *) let name = "My_extension" let version = "$Id$" end (* An extension is just a functor: Syntax -> Syntax *) module Make (Syntax : Sig.Syntax.S) = struct include Syntax let foo = Gram.Entry.mk "foo" open Camlp4.Sig.Camlp4Token EXTEND Gram GLOBAL: foo foo: [ [ "foo"; i = LIDENT; b = bar -> Foo(i, b) ] ]; bar: [ [ "?" -> A | "." -> B ] ]; END;; Gram.parse_string foo (Loc.mk "") "foo x?" = Foo("x", A) DELETE_RULE Gram foo end (* Register it to make it usable via the camlp4 binary. *) module M = Register.SyntaxExtension(Id)(Make) The first thing I am reasonably sure needs changing is Sig.Syntax.S doesn't seem to exist anymore, and judging by the signature of the Register.SyntaxExtension functor, we want a Sig.SyntaxExtension. If we make the parameter Syntax a Sig.Syntax then Make becomes a functor with signature Sig.SyntaxExtension. The next thing I figured out by looking at the translated json_static.ml, which is that GLOBAL: foo needs to be GLOBAL: foo; To avert a syntax error. Likewise, the DELETE_RULE seems to upset the lexer with syntax errors: ~/src/camlp4-beta jehenrik$ ocamlc -I +camlp4 -I +camlp4/Camlp4Parsers -pp camlp4orf camlp4.cma -c dynamic_functor_example3.ml File "dynamic_functor_example3.ml", line 21, characters 19-22: Parse error: [name] expected after [qualuid] (in [delete_rule_body]) Preprocessor error I don't know what to do about this, so I'll temporarily delete the DELETE_RULE just so that I can get on to the other errors. The closest I can see to making it compile, in a possibly defective state: (* An extension is just a functor: Syntax -> Syntax *) -module Make (Syntax : Sig.Syntax.S) = struct +module Make (Syntax : Camlp4.Sig.Syntax) = struct include Syntax let foo = Gram.Entry.mk "foo" open Camlp4.Sig.Camlp4Token EXTEND Gram - GLOBAL: foo + GLOBAL: foo; foo: [ [ "foo"; i = LIDENT; b = bar -> Foo(i, b) ] ]; bar: [ [ "?" -> A | "." -> B ] ]; END;; Gram.parse_string foo (Loc.mk "") "foo x?" = Foo("x", A) - DELETE_RULE Gram foo end (* Register it to make it usable via the camlp4 binary. *) module M = Register.SyntaxExtension(Id)(Make) And yet there is still a symbol not found: ~/src/camlp4-beta jehenrik$ ocamlc -I +camlp4 -I +camlp4/Camlp4Parsers -pp camlp4orf camlp4.cma -c dynamic_functor_example3.ml File "dynamic_functor_example3.ml", line 14, characters 2-29: Unbound module Camlp4.Sig.Camlp4Token Which is an unbound because in the current version Camlp4, Camlp4.Sig.Camlp4Token is a module type, not a module. I have no idea what is intended here. BTW, my compilation string is: ocamlc -I +camlp4 -I +camlp4/Camlp4Parsers -pp camlp4orf camlp4.cma -c dynamic_functor_example3.ml Which I'm not totally sure is right. So that's the best I can do. Please help. The application I want to write is not feasible in the old camlp4, but I suspect may be possible in the new. Thanks for all the effort getting the system to the next level. Jeff Henrikson