Browse thread
[camlp4] str_item filters & toplevel?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2008-04-17 (14:18) |
From: | Martin Jambon <martin.jambon@e...> |
Subject: | [camlp4] str_item filters & toplevel? |
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