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--