Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Format
- open Camlp4.PreCast
- let printer =
- let module P = Camlp4.Printers.OCaml.Make(Syntax)
- in new P.printer ()
- let print e =
- printf "%s:@\n" (Loc.to_string (Ast.loc_of_expr e));
- printer#expr std_formatter e;
- printf "@\n"
- ;;
- let e = <:expr@here< 1 * 2 + 3 >> in
- print e;
- print <:expr@here< 1 + 2 * 3 >>;
- print <:expr@here< 1 * 2 * 3 >>;
- print <:expr@here< 1 * 2 ** 3 >>;
- print <:expr@here< 1 - 2 - 3 >>;
- print <:expr@here< 1 + 2 * 3 / 4 >>;
- print <:expr@here< 1 + 2 * 3 + 4 >>;
- print <:expr@here< 1 * 2 + 3 * 4 >>;
- (* Local Variables: *)
- (* compile-command: "ocamlc -o test_expr -pp camlp4of -I +camlp4 camlp4lib.cma test_expr.ml && ./test_expr" *)
- (* End: *)
Add Comment
Please, Sign In to add comment