Browse thread
Help with new camlp4
[
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: | -- (:) |
| From: | Joel Reymont <joelr1@g...> |
| Subject: | Re: [Caml-list] Help with new camlp4 |
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/