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=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6D842BC0A for ; Wed, 13 Jun 2007 16:14:42 +0200 (CEST) Received: from bdmail1.accesst.com (pop.bulldoghome.com [83.245.1.230]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5DEEfc0003853 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 13 Jun 2007 16:14:42 +0200 Received: from host-84-9-232-186.bulldogdsl.com ([84.9.232.186] helo=[192.168.123.191]) by bdmail1.accesst.com with esmtpa (Exim 4.50) id 1HyTXQ-0007Dg-Uk for caml-list@inria.fr; Wed, 13 Jun 2007 15:09:33 +0100 Message-ID: <466FFA15.9080406@ed.ac.uk> Date: Wed, 13 Jun 2007 15:07:17 +0100 From: Jeremy Yallop User-Agent: Mozilla-Thunderbird 2.0.0.0 (X11/20070601) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] building executables with camlp4 References: <466FCB46.1070304@ed.ac.uk> <466FED3B.3030405@ed.ac.uk> <466FF0D8.5060006@ed.ac.uk> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 466FFBD1.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 cmo:01 functor:01 sig:01 struct:01 syntax:01 sig:01 syntax:01 struct:01 prerr:01 endline:01 ocamlc:01 -pp:01 usr:01 Nicolas Pouillard wrote: > After thinking a little more, I can explain what's happening there is > two modes to get into Camlp4 pipeline. The first one is through > registration and the second one is through dyn-linking of cmo files on > the command line. > > Here your Minimal module is neither on the command line nor registered. > > To register it make a functor around your grammar extension and call > Camlp4.Register.OCamlSyntaxExtension. Thanks, Nicolas! Everything's working now. In case anyone else wants to do something similar, here's the fully working example: minimal.ml: open Camlp4.PreCast module Id : Camlp4.Sig.Id = struct let name = "minimal" let version = "1.0" end module Extension (Syntax : Camlp4.Sig.Camlp4Syntax) = struct include Syntax DELETE_RULE Gram str_item: "type"; type_declaration END EXTEND Gram str_item: [[ "type"; types = type_declaration -> <:str_item< type $types$ >> | "type"; types = type_declaration; "premiums" ; "(" ; "squigglier" ; ")" -> prerr_endline "squigglier!"; <:str_item< type $types$ >> ]]; END end module M = Camlp4.Register.OCamlSyntaxExtension(Id)(Extension) File input.ml: type x = int premiums ( squigglier ) Building: $ ocamlc -c -pp camlp4of -I /usr/local/ocaml/lib/ocaml/camlp4 minimal.ml $ ocamlc -g -linkall -I /usr/local/ocaml/lib/ocaml/camlp4 \ -o minimal \ camlp4lib.cma \ unix.cma \ Camlp4Parsers/Camlp4OCamlRevisedParser.cmo \ Camlp4Parsers/Camlp4OCamlParser.cmo \ Camlp4Printers/Camlp4OCamlPrinter.cmo \ minimal.cmo \ Camlp4Bin.cmo Running: $ ./minimal input.ml squigglier! type x = int Jeremy.