caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* compiling camlp4 dynamic_functor_example.ml
@ 2007-04-07 22:51 Jeff Henrikson
  2007-04-08 10:34 ` [Caml-list] " Nicolas Pouillard
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Henrikson @ 2007-04-07 22:51 UTC (permalink / raw)
  To: caml-list

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 "<string>") "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 "<string>") "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




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

* Re: [Caml-list] compiling camlp4 dynamic_functor_example.ml
  2007-04-07 22:51 compiling camlp4 dynamic_functor_example.ml Jeff Henrikson
@ 2007-04-08 10:34 ` Nicolas Pouillard
  2007-04-15  5:05   ` Jeff Henrikson
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Pouillard @ 2007-04-08 10:34 UTC (permalink / raw)
  To: Jeff Henrikson; +Cc: caml-list

Hello,

On 4/8/07, Jeff Henrikson <jehenrik@yahoo.com> wrote:
> 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.

Thanks.

> from http://gallium.inria.fr/~pouillar/camlp4-changes.html

I've updated it!

[...]

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

Right.

> The next thing I figured out by looking at the translated
> json_static.ml, which is that
>
>     GLOBAL: foo
>
> needs to be
>
>     GLOBAL: foo;

It always had to be like that (even in the previous web page, strange...)

> To avert a syntax error.
>
> Likewise, the DELETE_RULE seems to upset the lexer with syntax errors:

Yes, the DELETE_RULE example was br0ken.

[...]

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

Yes just open Camlp4.Sig to see the token type now.

> BTW, my compilation string is:
>
> ocamlc -I +camlp4 -I +camlp4/Camlp4Parsers -pp camlp4orf camlp4.cma -c
> dynamic_functor_example3.ml

-I +camlp4/Camlp4Parsers is useless since one doesn't use any
Camlp4*Parser module.

camlp4.cma no longer exists it's camlp4lib.cma but here it's also
useless since one doesn't link (-c)

ocamlc -I +camlp4 -pp camlp4orf -c dynamic_functor_example3.ml

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

Thanks for your porting efforts!

-- 
Nicolas Pouillard


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

* Re: [Caml-list] compiling camlp4 dynamic_functor_example.ml
  2007-04-08 10:34 ` [Caml-list] " Nicolas Pouillard
@ 2007-04-15  5:05   ` Jeff Henrikson
  2007-04-15  9:00     ` Nicolas Pouillard
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Henrikson @ 2007-04-15  5:05 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: caml-list

Sorry, there still seems to be an issue with the 
dynamic_functor_example.ml.  The version I got to compile still had a 
bit of functionality removed.

 > Yes just open Camlp4.Sig to see the token type now.

Really?  This seems to generate a type of conflict with the Syntax.Gram 
when LIDENT is used in an EXTEND.

dynamic_functor_example5 is the text on your page verbatim.
 
~/src/camlp4-beta jehenrik$ ocamlc -I +camlp4 -pp camlp4orf -c 
dynamic_functor_example5.ml
File "dynamic_functor_example5.ml", line 18, characters 20-30:
This expression has type (Camlp4.Sig.camlp4_token -> bool) * string
but is here used with type
  Gram.token_pattern = (Gram.Token.t -> bool) * string
Type Camlp4.Sig.camlp4_token is not compatible with type
  Gram.Token.t = Syntax.Token.t

Regards,


Jeff Henrikson





Nicolas Pouillard wrote:
> Hello,
>
> On 4/8/07, Jeff Henrikson <jehenrik@yahoo.com> wrote:
>> 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.
>
> Thanks.
>
>> from http://gallium.inria.fr/~pouillar/camlp4-changes.html
>
> I've updated it!
>
> [...]
>
>> 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.
>
> Right.
>
>> The next thing I figured out by looking at the translated
>> json_static.ml, which is that
>>
>>     GLOBAL: foo
>>
>> needs to be
>>
>>     GLOBAL: foo;
>
> It always had to be like that (even in the previous web page, strange...)
>
>> To avert a syntax error.
>>
>> Likewise, the DELETE_RULE seems to upset the lexer with syntax errors:
>
> Yes, the DELETE_RULE example was br0ken.
>
> [...]
>
>> 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.
>
> Yes just open Camlp4.Sig to see the token type now.
>
>> BTW, my compilation string is:
>>
>> ocamlc -I +camlp4 -I +camlp4/Camlp4Parsers -pp camlp4orf camlp4.cma -c
>> dynamic_functor_example3.ml
>
> -I +camlp4/Camlp4Parsers is useless since one doesn't use any
> Camlp4*Parser module.
>
> camlp4.cma no longer exists it's camlp4lib.cma but here it's also
> useless since one doesn't link (-c)
>
> ocamlc -I +camlp4 -pp camlp4orf -c dynamic_functor_example3.ml
>
>> 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.
>
> Thanks for your porting efforts!
>


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

* Re: [Caml-list] compiling camlp4 dynamic_functor_example.ml
  2007-04-15  5:05   ` Jeff Henrikson
@ 2007-04-15  9:00     ` Nicolas Pouillard
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Pouillard @ 2007-04-15  9:00 UTC (permalink / raw)
  To: Jeff Henrikson; +Cc: caml-list

On 4/15/07, Jeff Henrikson <jehenrik@yahoo.com> wrote:
> Sorry, there still seems to be an issue with the
> dynamic_functor_example.ml.  The version I got to compile still had a
> bit of functionality removed.

Ok, sorry it's now really updated.

Since the token type can be changed the Camlp4.Sig.Syntax don't rely
directly on it. That's why I have switched to Campl4.Sig.Camlp4Syntax
(and Register.OCamlSyntaxExtension) in the example.

>
>  > Yes just open Camlp4.Sig to see the token type now.
>
> Really?  This seems to generate a type of conflict with the Syntax.Gram
> when LIDENT is used in an EXTEND.
>
> dynamic_functor_example5 is the text on your page verbatim.
>
> ~/src/camlp4-beta jehenrik$ ocamlc -I +camlp4 -pp camlp4orf -c
> dynamic_functor_example5.ml
> File "dynamic_functor_example5.ml", line 18, characters 20-30:
> This expression has type (Camlp4.Sig.camlp4_token -> bool) * string
> but is here used with type
>   Gram.token_pattern = (Gram.Token.t -> bool) * string
> Type Camlp4.Sig.camlp4_token is not compatible with type
>   Gram.Token.t = Syntax.Token.t
>
> Regards,
>
>
> Jeff Henrikson
>
>
>
>
>
> Nicolas Pouillard wrote:
> > Hello,
> >
> > On 4/8/07, Jeff Henrikson <jehenrik@yahoo.com> wrote:
> >> 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.
> >
> > Thanks.
> >
> >> from http://gallium.inria.fr/~pouillar/camlp4-changes.html
> >
> > I've updated it!
> >
> > [...]
> >
> >> 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.
> >
> > Right.
> >
> >> The next thing I figured out by looking at the translated
> >> json_static.ml, which is that
> >>
> >>     GLOBAL: foo
> >>
> >> needs to be
> >>
> >>     GLOBAL: foo;
> >
> > It always had to be like that (even in the previous web page, strange...)
> >
> >> To avert a syntax error.
> >>
> >> Likewise, the DELETE_RULE seems to upset the lexer with syntax errors:
> >
> > Yes, the DELETE_RULE example was br0ken.
> >
> > [...]
> >
> >> 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.
> >
> > Yes just open Camlp4.Sig to see the token type now.
> >
> >> BTW, my compilation string is:
> >>
> >> ocamlc -I +camlp4 -I +camlp4/Camlp4Parsers -pp camlp4orf camlp4.cma -c
> >> dynamic_functor_example3.ml
> >
> > -I +camlp4/Camlp4Parsers is useless since one doesn't use any
> > Camlp4*Parser module.
> >
> > camlp4.cma no longer exists it's camlp4lib.cma but here it's also
> > useless since one doesn't link (-c)
> >
> > ocamlc -I +camlp4 -pp camlp4orf -c dynamic_functor_example3.ml
> >
> >> 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.
> >
> > Thanks for your porting efforts!
> >
>
>


-- 
Nicolas Pouillard aka Ertai  <ertai@feydakins.org>
http://uttk.org      Uttk -- Unified Test Tool Kit


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

end of thread, other threads:[~2007-04-15  9:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-07 22:51 compiling camlp4 dynamic_functor_example.ml Jeff Henrikson
2007-04-08 10:34 ` [Caml-list] " Nicolas Pouillard
2007-04-15  5:05   ` Jeff Henrikson
2007-04-15  9:00     ` Nicolas Pouillard

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