caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Help with new camlp4
@ 2007-04-02  8:33 Joel Reymont
  2007-04-02  9:14 ` [Caml-list] " Nicolas Pouillard
  0 siblings, 1 reply; 12+ messages in thread
From: Joel Reymont @ 2007-04-02  8:33 UTC (permalink / raw)
  To: Caml List

Folks,

This error

File "q_octal.ml", line 183, characters 40-49:
While expanding quotation "expr":
   Parse error: "::" or "]" expected after [sem_patt_for_list] (in  
[patt])

Points to $lid:name$ in the following bit of code

                         (<:expr<
                                 match $exp$ with
                                 [ Some $lid:name$ -> $subast$ | None  
-> []]
                         >>, StringSet.add var (StringSet.remove name  
vars), true

How do I fix this in the new camlp4 and where is this documented?

	Thanks, Joel

--
http://wagerlabs.com/






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

* Re: [Caml-list] Help with new camlp4
  2007-04-02  8:33 Help with new camlp4 Joel Reymont
@ 2007-04-02  9:14 ` Nicolas Pouillard
  2007-04-02  9:21   ` Joel Reymont
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Pouillard @ 2007-04-02  9:14 UTC (permalink / raw)
  To: Joel Reymont; +Cc: Caml List

On 4/2/07, Joel Reymont <joelr1@gmail.com> wrote:
> Folks,
>
> This error
>
> File "q_octal.ml", line 183, characters 40-49:
> While expanding quotation "expr":
>    Parse error: "::" or "]" expected after [sem_patt_for_list] (in
> [patt])
>
> Points to $lid:name$ in the following bit of code
>
>                          (<:expr<
>                                  match $exp$ with
>                                  [ Some $lid:name$ -> $subast$ | None
> -> []]
>                          >>, StringSet.add var (StringSet.remove name
> vars), true
>
> How do I fix this in the new camlp4 and where is this documented?
>

It depends on the camlp4 used. I think that you want to use camlp4orf
to compile that code.

-- 
Nicolas Pouillard


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

* Re: [Caml-list] Help with new camlp4
  2007-04-02  9:14 ` [Caml-list] " Nicolas Pouillard
@ 2007-04-02  9:21   ` Joel Reymont
  2007-04-02  9:23     ` Joel Reymont
  0 siblings, 1 reply; 12+ messages in thread
From: Joel Reymont @ 2007-04-02  9:21 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: Caml List


On Apr 2, 2007, at 10:14 AM, Nicolas Pouillard wrote:

> It depends on the camlp4 used. I think that you want to use camlp4orf
> to compile that code.

I'm compiling Octal[1] and used camlp4of previously. Trying camlp4orf  
but get

ocamlc.opt -c -I +camlp4 -pp 'camlp4orf -loc loc' q_octal.ml
File "q_octal.ml", line 23, characters 10-25:
Unbound value Token.dummy_loc

on

let loc = Token.dummy_loc ;;

Digging around now...

	Thanks, Joel

[1] http://ssel.vub.ac.be/svn-gen/bdefrain/octal/

--
http://wagerlabs.com/






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

* Re: [Caml-list] Help with new camlp4
  2007-04-02  9:21   ` Joel Reymont
@ 2007-04-02  9:23     ` Joel Reymont
  2007-04-02  9:28       ` Nicolas Pouillard
  0 siblings, 1 reply; 12+ messages in thread
From: Joel Reymont @ 2007-04-02  9:23 UTC (permalink / raw)
  To: Caml List


On Apr 2, 2007, at 10:21 AM, Joel Reymont wrote:

> ocamlc.opt -c -I +camlp4 -pp 'camlp4orf -loc loc' q_octal.ml
> File "q_octal.ml", line 23, characters 10-25:
> Unbound value Token.dummy_loc
>
> on
>
> let loc = Token.dummy_loc ;;

This is easy, actually.

open Camlp4.PreCast

let loc = Loc.ghost

--
http://wagerlabs.com/






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

* Re: [Caml-list] Help with new camlp4
  2007-04-02  9:23     ` Joel Reymont
@ 2007-04-02  9:28       ` Nicolas Pouillard
  2007-04-02 12:24         ` Joel Reymont
  2007-04-02 12:40         ` Joel Reymont
  0 siblings, 2 replies; 12+ messages in thread
From: Nicolas Pouillard @ 2007-04-02  9:28 UTC (permalink / raw)
  To: Joel Reymont; +Cc: Caml List

On 4/2/07, Joel Reymont <joelr1@gmail.com> wrote:
>
> On Apr 2, 2007, at 10:21 AM, Joel Reymont wrote:
>
> > ocamlc.opt -c -I +camlp4 -pp 'camlp4orf -loc loc' q_octal.ml
> > File "q_octal.ml", line 23, characters 10-25:
> > Unbound value Token.dummy_loc
> >
> > on
> >
> > let loc = Token.dummy_loc ;;
>
> This is easy, actually.
>
> open Camlp4.PreCast
>
> let loc = Loc.ghost

That's it.

Indeed http://gallium.inria.fr/~pouillar/camlp4-changes.html explain
some of these common changes.

There is also some things that you can digg in that translation:
http://martin.jambon.free.fr/examples/pa_json_static_3100beta.html

-- 
Nicolas Pouillard


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

* Re: [Caml-list] Help with new camlp4
  2007-04-02  9:28       ` Nicolas Pouillard
@ 2007-04-02 12:24         ` Joel Reymont
  2007-04-02 12:30           ` Joel Reymont
  2007-04-02 12:40         ` Joel Reymont
  1 sibling, 1 reply; 12+ messages in thread
From: Joel Reymont @ 2007-04-02 12:24 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: Caml List


On Apr 2, 2007, at 10:28 AM, Nicolas Pouillard wrote:

> Indeed http://gallium.inria.fr/~pouillar/camlp4-changes.html explain
> some of these common changes.

How do you do the following?

Quotation.add "octalxml" (Quotation.ExAst  
(expand_expr_str,expand_patt)) ;;
Quotation.add "octalfile" (Quotation.ExAst  
(expand_expr_file,expand_patt)) ;;

I get an error:

This expression has type string -> Camlp4.PreCast.Ast.expr
but is here used with type
   Camlp4.PreCast.Quotation.Ast.expr  
Camlp4.PreCast.Quotation.expand_fun =
     Camlp4.PreCast.Quotation.Ast.Loc.t ->
     string option -> string -> Camlp4.PreCast.Quotation.Ast.expr
Type string is not compatible with type
   Camlp4.PreCast.Quotation.Ast.Loc.t = Camlp4.PreCast.Loc.t
make: *** [q_octal.cmo] Error 2

--
http://wagerlabs.com/






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

* Re: [Caml-list] Help with new camlp4
  2007-04-02 12:24         ` Joel Reymont
@ 2007-04-02 12:30           ` Joel Reymont
  2007-04-02 13:47             ` Gabriel Kerneis
  0 siblings, 1 reply; 12+ messages in thread
From: Joel Reymont @ 2007-04-02 12:30 UTC (permalink / raw)
  To: Caml List


On Apr 2, 2007, at 1:24 PM, Joel Reymont wrote:

> How do you do the following?
>
> Quotation.add "octalxml" (Quotation.ExAst  
> (expand_expr_str,expand_patt)) ;;
> Quotation.add "octalfile" (Quotation.ExAst  
> (expand_expr_file,expand_patt)) ;;

expand_expr_str has to have a particular signature, i.e.

let expand_str_expr loc loc_name_opt s

and it doesn't. Working on it...

--
http://wagerlabs.com/






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

* Re: [Caml-list] Help with new camlp4
  2007-04-02  9:28       ` Nicolas Pouillard
  2007-04-02 12:24         ` Joel Reymont
@ 2007-04-02 12:40         ` Joel Reymont
  2007-04-02 12:44           ` Joel Reymont
  1 sibling, 1 reply; 12+ messages in thread
From: Joel Reymont @ 2007-04-02 12:40 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: Caml List

I'm stuck for good now.

I'm trying to make sure that translate has a proper signature. It  
needs a few arguments that weren't present in the original  
declaration (let translate xml = ...). I add the missing bits but xml  
in translate is of type Xml whereas Quotation.ExAst wants a string.

Help!!!

let translate (_: Quotation.Ast.Loc.t) (_:string option) (xml: string) =
   let (body,vars,sublist) = visit StringSet.empty xml in
     if sublist then
       failwith "Need exactly 1 root (condition/repeat/omit-tag  
prohibited)"
     else
       let vvars = List.map (fun x -> <:patt< ~ $x$>>)  
(StringSet.elements vars) in
         List.fold_right (fun p e -> <:expr<fun $p$ -> $e$>>) vvars body
;;

let expand_expr_file = chain translate Xml.parse_file ;;

let expand_expr_str = chain translate Xml.parse_string ;;

let expand_patt x =
(*  Stdpp.raise_with_loc loc *)
   Loc.raise x (Failure "Quotation not allowed in pattern")
;;

Quotation.add "octalxml" (Quotation.ExAst  
(expand_expr_str,expand_patt)) ;;
Quotation.add "octalfile" (Quotation.ExAst  
(expand_expr_file,expand_patt)) ;;


--
http://wagerlabs.com/






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

* Re: [Caml-list] Help with new camlp4
  2007-04-02 12:40         ` Joel Reymont
@ 2007-04-02 12:44           ` Joel Reymont
  0 siblings, 0 replies; 12+ messages in thread
From: Joel Reymont @ 2007-04-02 12:44 UTC (permalink / raw)
  To: Caml List

I hereby declare victory!

let expand_expr_file _ _ s = translate (Xml.parse_file s) ;;

let expand_expr_str _ _ s = translate (Xml.parse_string s);;

let expand_patt x =
(*  Stdpp.raise_with_loc loc *)
   Loc.raise x (Failure "Quotation not allowed in pattern")
;;

--
http://wagerlabs.com/






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

* Re: [Caml-list] Help with new camlp4
  2007-04-02 12:30           ` Joel Reymont
@ 2007-04-02 13:47             ` Gabriel Kerneis
  2007-04-02 13:54               ` Joel Reymont
  0 siblings, 1 reply; 12+ messages in thread
From: Gabriel Kerneis @ 2007-04-02 13:47 UTC (permalink / raw)
  To: caml-list

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

Le Mon, 2 Apr 2007 13:30:26 +0100, Joel Reymont <joelr1@gmail.com> a
écrit :
> 
> On Apr 2, 2007, at 1:24 PM, Joel Reymont wrote:
> 
> > How do you do the following?
> >
> > Quotation.add "octalxml" (Quotation.ExAst  
> > (expand_expr_str,expand_patt)) ;;
> > Quotation.add "octalfile" (Quotation.ExAst  
> > (expand_expr_file,expand_patt)) ;;
> 
> expand_expr_str has to have a particular signature, i.e.
> 
> let expand_str_expr loc loc_name_opt s
> 
> and it doesn't. Working on it...

It changed a few days ago. Look at the end of
ocaml/camlp4/examples/lambda_quot.ml

Regards,
-- 
Gabriel

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [Caml-list] Help with new camlp4
  2007-04-02 13:47             ` Gabriel Kerneis
@ 2007-04-02 13:54               ` Joel Reymont
  2007-04-02 17:15                 ` Nicolas Pouillard
  0 siblings, 1 reply; 12+ messages in thread
From: Joel Reymont @ 2007-04-02 13:54 UTC (permalink / raw)
  To: Gabriel Kerneis; +Cc: caml-list


On Apr 2, 2007, at 2:47 PM, Gabriel Kerneis wrote:

> It changed a few days ago. Look at the end of
> ocaml/camlp4/examples/lambda_quot.ml

There must be something wrong with my cvs. I'm doing cvs update in  
the tree and it's not pulling in new camlp4 examples.

--
http://wagerlabs.com/






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

* Re: [Caml-list] Help with new camlp4
  2007-04-02 13:54               ` Joel Reymont
@ 2007-04-02 17:15                 ` Nicolas Pouillard
  0 siblings, 0 replies; 12+ messages in thread
From: Nicolas Pouillard @ 2007-04-02 17:15 UTC (permalink / raw)
  To: Joel Reymont; +Cc: Gabriel Kerneis, caml-list

On 4/2/07, Joel Reymont <joelr1@gmail.com> wrote:
>
> On Apr 2, 2007, at 2:47 PM, Gabriel Kerneis wrote:
>
> > It changed a few days ago. Look at the end of
> > ocaml/camlp4/examples/lambda_quot.ml
>
> There must be something wrong with my cvs. I'm doing cvs update in
> the tree and it's not pulling in new camlp4 examples.

cvs up -dP -r release310 ?

-- 
Nicolas Pouillard


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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-02  8:33 Help with new camlp4 Joel Reymont
2007-04-02  9:14 ` [Caml-list] " Nicolas Pouillard
2007-04-02  9:21   ` Joel Reymont
2007-04-02  9:23     ` Joel Reymont
2007-04-02  9:28       ` Nicolas Pouillard
2007-04-02 12:24         ` Joel Reymont
2007-04-02 12:30           ` Joel Reymont
2007-04-02 13:47             ` Gabriel Kerneis
2007-04-02 13:54               ` Joel Reymont
2007-04-02 17:15                 ` Nicolas Pouillard
2007-04-02 12:40         ` Joel Reymont
2007-04-02 12:44           ` Joel Reymont

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