caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [camlp4] str_item filters & toplevel?
@ 2008-04-17 14:17 Martin Jambon
  2008-04-17 14:42 ` [Caml-list] " Nicolas Pouillard
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Jambon @ 2008-04-17 14:17 UTC (permalink / raw)
  To: caml-list

I started from the wiki page describing how to use AST filters:
http://brion.inria.fr/gallium/index.php/Camlp4MapGenerator

The example doesn't work in the toplevel (3.10.1), although it works 
otherwise. How to make it work?

Here is my testing session:

$ cat simplify.ml
open Camlp4.PreCast

let simplify = Ast.map_expr begin function
   | <:expr< $x$ + zero >> | <:expr< zero + $x$ >> -> x
   | x -> x
end
in AstFilters.register_str_item_filter simplify#str_item

let _ =
   prerr_string "Loaded \"simplify\"\n";
   flush stderr

$ ocamlc -c -pp camlp4of -I +camlp4 simplify.ml

$ \ocaml -I +camlp4 camlp4lib.cma simplify.cmo
Loaded "simplify"
         Objective Caml version 3.10.1

# 1 + zero;;
Unbound value zero
#

$ camlp4o ./simplify.cmo -str '1 + zero'
Loaded "simplify"
1




--
http://wink.com/profile/mjambon
http://mjambon.com


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

end of thread, other threads:[~2008-04-18  7:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-17 14:17 [camlp4] str_item filters & toplevel? Martin Jambon
2008-04-17 14:42 ` [Caml-list] " Nicolas Pouillard
2008-04-17 15:25   ` Martin Jambon
2008-04-17 18:35     ` Nicolas Pouillard
2008-04-17 19:19       ` Martin Jambon
2008-04-18  7:19         ` 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).