From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id AEEBDBC37 for ; Thu, 11 Feb 2010 19:55:47 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak0BAI/hc0tKfU4ZkGdsb2JhbACPQgGKYVEIFQEBAQEJCQwHEwMgh3O3KIRWBA X-IronPort-AV: E=Sophos;i="4.49,453,1262559600"; d="scan'208";a="44508023" Received: from ey-out-2122.google.com ([74.125.78.25]) by mail2-smtp-roc.national.inria.fr with ESMTP; 11 Feb 2010 19:55:47 +0100 Received: by ey-out-2122.google.com with SMTP id 9so39074eyd.7 for ; Thu, 11 Feb 2010 10:55:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.213.109.77 with SMTP id i13mr193419ebp.82.1265914546819; Thu, 11 Feb 2010 10:55:46 -0800 (PST) Date: Thu, 11 Feb 2010 18:55:46 +0000 Message-ID: <9722eaea1002111055q7f571aeu1797760f58ad4dd5@mail.gmail.com> Subject: another camlp4 question From: Thomas Gazagnaire To: caml-list@inria.fr Content-Type: multipart/alternative; boundary=000e0cdf93eae114f3047f57b294 X-Spam: no; 0.00; camlp:01 ocaml:01 camlp:01 ocaml:01 syntax:01 clashes:01 syntax:01 cheers:01 foo:01 sig:01 sig:01 lident:01 val:01 foo:01 compilation:01 --000e0cdf93eae114f3047f57b294 Content-Type: text/plain; charset=ISO-8859-1 Dear camlp4 gurus, I am looking to extend the ocaml syntax to add some keyword to module signatures (in a similar way the type-conv module does for type definition). However I am stuck with a very basic example. Can anyone tell me what's wrong here ? It seems that my extension clashes with 'module_type t ::= mt with wc' in http://brion.inria.fr/gallium/index.php/Abstract_Syntax_Tree#Module_typesbut I still have the same problem if I change the 'with' keyword to 'where'. Cheers, Thomas === foo.ml === open Camlp4 open PreCast open Ast open Syntax EXTEND Gram GLOBAL: sig_item; sig_item: [[ "module"; "type"; i = a_UIDENT; "="; mt = module_type; "with"; id = LIDENT -> <:sig_item< module type $uid:i ^ "_" ^ id$ = $mt$; >> ]]; END === === test.ml === module type S = sig val x : unit -> unit end with foo === === compilation $ ocamlfind ocamlc -package camlp4 -c -pp "camlp4orf" foo.ml $ camlp4o foo.cmo test.ml File "foo.ml", line 3, characters 4-8: Parse error: [with_constr] expected after "with" (in [module_type]) === --000e0cdf93eae114f3047f57b294 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Dear camlp4 gurus,

I am looking to extend the ocaml syntax to add so= me keyword to module signatures (in a similar way the type-conv module does= for type definition). However I am stuck with a very basic example. Can an= yone tell me what's wrong here ? It seems that my extension clashes wit= h 'module_type t ::=3D mt with wc' in http://brion.inria= .fr/gallium/index.php/Abstract_Syntax_Tree#Module_types but I still hav= e the same problem if I change the 'with' keyword to 'where'= ;.

Cheers,
Thomas

=3D=3D=3D foo.ml= =3D=3D=3D
open Camlp4
open PreCast
open Ast
open Syntax
EXTEND Gram

GLOBAL: sig_item;

sig_item:=A0 [[
=A0=A0=A0 &= quot;module"; "type"; i =3D a_UIDENT; "=3D"; mt = =3D module_type; "with"; id =3D LIDENT ->
=A0=A0=A0 =A0=A0=A0 <:sig_item< module type $uid:i ^ "_" ^ = id$ =3D $mt$; >>
=A0=A0=A0 ]];
END
=3D=3D=3D

=3D=3D= =3D test.ml =3D=3D=3D
module type S =3D s= ig
=A0=A0=A0 val x : unit -> unit
end with foo
=3D=3D=3D

=3D=3D=3D compilation
$=A0 ocamlfind ocamlc -package ca= mlp4 -c -pp "camlp4orf" foo.ml
$= camlp4o foo.cmo test.ml
File "foo.ml", line 3, characters 4-8:
Parse error: [with_constr] expected after "with" (in [module_type= ])
=3D=3D=3D

--000e0cdf93eae114f3047f57b294-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 0532DBC37 for ; Fri, 12 Feb 2010 13:16:10 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhUBAE7VdEvRVdvdkGdsb2JhbACaeggVAQEBAQkJDAcTAyC+QoRYBA X-IronPort-AV: E=Sophos;i="4.49,460,1262559600"; d="scan'208";a="56934422" Received: from mail-ew0-f221.google.com ([209.85.219.221]) by mail4-smtp-sop.national.inria.fr with ESMTP; 12 Feb 2010 13:16:09 +0100 Received: by ewy21 with SMTP id 21so2767224ewy.22 for ; Fri, 12 Feb 2010 04:16:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.213.1.151 with SMTP id 23mr15349ebf.34.1265976969375; Fri, 12 Feb 2010 04:16:09 -0800 (PST) In-Reply-To: <9722eaea1002111055q7f571aeu1797760f58ad4dd5@mail.gmail.com> References: <9722eaea1002111055q7f571aeu1797760f58ad4dd5@mail.gmail.com> Date: Fri, 12 Feb 2010 12:16:09 +0000 Message-ID: <9722eaea1002120416s72a7e1e6u9730b755aa3e4ef1@mail.gmail.com> Subject: Re: another camlp4 question From: Thomas Gazagnaire To: caml-list@inria.fr Content-Type: multipart/alternative; boundary=000e0ce029f68dae7e047f663b61 X-Spam: no; 0.00; camlp:01 ocaml:01 sig:01 sig:01 lident:01 lident:01 module:03 module:03 extend:07 extend:07 definition:07 definition:07 gram:11 gram:11 end:12 --000e0ce029f68dae7e047f663b61 Content-Type: text/plain; charset=ISO-8859-1 To answer to myself: EXTEND Gram > > GLOBAL: sig_item; > > sig_item: [[ > "module"; "type"; i = a_UIDENT; "="; mt = module_type; "with"; id = > LIDENT -> > <:sig_item< module type $uid:i ^ "_" ^ id$ = $mt$; >> > ]]; > END > should have been: str_item instead of sig_item + any keyword different from "with" after the signature definition. - Thomas --000e0ce029f68dae7e047f663b61 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable To answer to myself:

EXTEND Gram

GLOBAL: sig_item;<= br>
sig_item:=A0 [[
=A0=A0=A0 "module"; "type"; i = =3D a_UIDENT; "=3D"; mt =3D module_type; "with"; id =3D= LIDENT ->
=A0=A0=A0 =A0=A0=A0 <:sig_item< module type $uid:i ^ "_" ^ = id$ =3D $mt$; >>
=A0=A0=A0 ]];
END

sh= ould have been: str_item instead of sig_item + any keyword different from &= quot;with" after the signature definition.

- Thomas
--000e0ce029f68dae7e047f663b61--