caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: Nicolas Pouillard <nicolas.pouillard@gmail.com>
Cc: "Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Help with new camlp4
Date: Mon, 2 Apr 2007 13:40:26 +0100	[thread overview]
Message-ID: <55D63C07-BC8F-424C-A895-55587FD97EB3@gmail.com> (raw)
In-Reply-To: <cd67f63a0704020228w2c2ccf56q89f4d414cf66738a@mail.gmail.com>

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/






  parent reply	other threads:[~2007-04-02 12:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-02  8:33 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 [this message]
2007-04-02 12:44           ` Joel Reymont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55D63C07-BC8F-424C-A895-55587FD97EB3@gmail.com \
    --to=joelr1@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=nicolas.pouillard@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).