camlp4: even more test fixtures
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9034 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
f0de463f28
commit
ff4580e3b8
|
@ -0,0 +1,7 @@
|
|||
open Camlp4.PreCast;;
|
||||
Camlp4_config.antiquotations := true;;
|
||||
let expand_my_quot_expr _loc _loc_name_opt quotation_contents =
|
||||
Printf.eprintf "%S\n%!" quotation_contents;
|
||||
<:expr< dummy >>
|
||||
;;
|
||||
Syntax.Quotation.add "my" Syntax.Quotation.DynAst.expr_tag expand_my_quot_expr;;
|
|
@ -0,0 +1,5 @@
|
|||
#load "camlp4of.cma";;
|
||||
open Camlp4.PreCast;;
|
||||
module M = Ast.Meta.Make(Ast.Meta.MetaGhostLoc);;
|
||||
let ghost = Loc.ghost;;
|
||||
M.Expr.meta_ctyp ghost <:ctyp@ghost< int >>;;
|
|
@ -0,0 +1,24 @@
|
|||
open Camlp4.PreCast
|
||||
|
||||
let _loc = Loc.mk "?"
|
||||
|
||||
let base base fields ty =
|
||||
let fields = List.fold_right (fun field acc ->
|
||||
let c = <:ctyp< $lid:field$ : $uid:field$.record >> in
|
||||
<:ctyp< $c$ ; $acc$ >>) fields <:ctyp< >>
|
||||
in
|
||||
<:module_binding< $uid:base$ :
|
||||
sig type record = {
|
||||
key : $ty$;
|
||||
$fields$
|
||||
} end = struct
|
||||
type record = {
|
||||
key : $ty$;
|
||||
$fields$
|
||||
} end
|
||||
>>
|
||||
|
||||
let _ =
|
||||
let b = base "b" ["f1"; "f2"] <:ctyp< int >> in
|
||||
Camlp4.PreCast.Printers.OCaml.print_implem
|
||||
<:str_item< module rec $b$ >>
|
Loading…
Reference in New Issue