caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* another camlp4 question
@ 2010-02-11 18:55 Thomas Gazagnaire
  2010-02-12 12:16 ` Thomas Gazagnaire
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Gazagnaire @ 2010-02-11 18:55 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]

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])
===

[-- Attachment #2: Type: text/html, Size: 1535 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: another camlp4 question
  2010-02-11 18:55 another camlp4 question Thomas Gazagnaire
@ 2010-02-12 12:16 ` Thomas Gazagnaire
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gazagnaire @ 2010-02-12 12:16 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 368 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 651 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-12 12:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-11 18:55 another camlp4 question Thomas Gazagnaire
2010-02-12 12:16 ` Thomas Gazagnaire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).