From: Jeremy Yallop <jeremy.yallop@ed.ac.uk>
To: Richard Jones <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] camlp4 question: Mixing a printer and Ast.fold
Date: Fri, 21 Mar 2008 15:36:11 +0000 [thread overview]
Message-ID: <47E3D5EB.5050502@ed.ac.uk> (raw)
In-Reply-To: <20080321150639.GA29482@annexia.org>
Richard Jones wrote:
> I cannot for the life of me work out how to get this to compile. I've
> tried about a dozen different variations of the module names, 'open',
> 'include' etc. and got a dozen different errors.
Here's another variation that compiles and seems to work. I changed the
following:
* the argument type to Make from "Syntax" to "Camlp4Syntax"
* the register functor from "Printer" to "OCamlPrinter"
* the accumulated value in "expr" from "str" to "singular".
Jeremy.
module Id = struct
let name = "pr_gettext"
let version = "$Id$"
end
module Make (Syntax : Camlp4.Sig.Camlp4Syntax)
: Camlp4.Sig.Printer(Syntax.Ast).S =
struct
open Syntax
class visitor = object
inherit Ast.fold as super
val t = []
method t = t
method expr = function
| <:expr@loc< f $str:singular$ >> ->
let t = singular :: t in
{< t = t >}
| e -> super#expr e
end
let print_interf ?input_file ?output_file _ = ()
let print_implem ?input_file ?output_file ast =
let visitor = (new visitor)#str_item in
let t = (visitor ast)#t in
List.iter prerr_endline t
end
(* Register the new printer. *)
module M = Camlp4.Register.OCamlPrinter(Id)(Make)
next prev parent reply other threads:[~2008-03-21 15:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-21 15:06 Richard Jones
2008-03-21 15:36 ` Jeremy Yallop [this message]
2008-03-21 15:51 ` [Caml-list] " Richard Jones
2008-03-21 15:46 ` Nicolas Pouillard
2008-03-21 15:58 ` Richard Jones
2008-03-26 9:29 ` Sylvain Le Gall
2008-03-21 16:44 ` [Caml-list] " Richard Jones
2008-03-21 16:50 ` Nicolas Pouillard
2008-03-21 16:56 ` Richard Jones
2008-03-21 17:03 ` Nicolas Pouillard
2008-03-21 17:21 ` Richard Jones
2008-03-21 20:19 ` Richard Jones
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=47E3D5EB.5050502@ed.ac.uk \
--to=jeremy.yallop@ed.ac.uk \
--cc=caml-list@inria.fr \
--cc=rich@annexia.org \
/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