diff options
| author | Alain Frisch <alain@frisch.fr> | 2013-06-03 15:14:19 +0000 |
|---|---|---|
| committer | Alain Frisch <alain@frisch.fr> | 2013-06-03 15:14:19 +0000 |
| commit | b5df2ef53a1fd571c2b8536c572632beba6ac7a6 (patch) | |
| tree | ccf35aaf3ae3d812b96322ae72d6224a157410db /experimental | |
| parent | f50d54c92b76b90a8d0c282622ddf28dae24ae30 (diff) | |
| download | ocaml-b5df2ef53a1fd571c2b8536c572632beba6ac7a6.tar.gz | |
Item attributes on each let-binding.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13736 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'experimental')
| -rw-r--r-- | experimental/frisch/Makefile | 7 | ||||
| -rw-r--r-- | experimental/frisch/extension_points.txt | 16 | ||||
| -rw-r--r-- | experimental/frisch/genlifter.ml | 2 | ||||
| -rw-r--r-- | experimental/frisch/js_syntax.ml | 2 | ||||
| -rw-r--r-- | experimental/frisch/ppx_builder.ml | 4 |
5 files changed, 21 insertions, 10 deletions
diff --git a/experimental/frisch/Makefile b/experimental/frisch/Makefile index 9bfa9b87b3..9cf8966372 100644 --- a/experimental/frisch/Makefile +++ b/experimental/frisch/Makefile @@ -71,3 +71,10 @@ copy_typedef: $(OCAMLC) -linkall -o copy_typedef.exe -w +A-4 $(COMMON) copy_typedef.ml $(OCAMLC) -c -ppx ./copy_typedef.exe test_copy_typedef.mli $(OCAMLC) -o test_copy_typedef.exe -w +A -ppx ./copy_typedef.exe -dsource test_copy_typedef.ml + + +## Create mli files from ml files + +.PHONY: nomli +nomli: + $(OCAMLC) -linkall -o nomli.exe -w +A-4-9 $(COMMON) $(BYTECMP) ../../tools/untypeast.cmo ../../tools/tast_iter.cmo nomli.ml diff --git a/experimental/frisch/extension_points.txt b/experimental/frisch/extension_points.txt index 2dc879d300..ed7fc20613 100644 --- a/experimental/frisch/extension_points.txt +++ b/experimental/frisch/extension_points.txt @@ -41,10 +41,12 @@ Attributes on items: ... [@@id s] - Items designate signature items, structure items, class fields, - class type fields and also individual components of multiple - declaration in structures and signatures (type declarations, recursive modules, class - declarations, class type declarations). + Items designate: + - structure and signature items (for type declarations, recursive modules, class + declarations and class type declarations, each component has its own attributes) + - class fields and class type fields + - each binding in a let declaration (for let structure item, local let-bindings in + expression and class expressions) For instance, consider: @@ -53,8 +55,10 @@ Attributes on items: Here, the attributes on t1 are id1, id23; the attributes on t2 are id3 and id4. - Note: item attributes are currently not supported on Pstr_eval - and Pstr_value structure items. + Similarly for: + + let x1 = ... [@@id1] [@@id2] and x2 = ... [@@id3] [@@id4] + The [@@id s] form, when used at the beginning of a signature or structure, or after a double semi-colon (;;), defines an attribute diff --git a/experimental/frisch/genlifter.ml b/experimental/frisch/genlifter.ml index 095013e217..d39066eaa8 100644 --- a/experimental/frisch/genlifter.ml +++ b/experimental/frisch/genlifter.ml @@ -105,7 +105,7 @@ and tyexpr env ty x = app f [x] | Ttuple tl -> let p, e = gentuple env tl in - let_in [Pat.tuple p, x] (selfcall "tuple" [list e]) + let_in [Vb.mk (Pat.tuple p) x] (selfcall "tuple" [list e]) | Tconstr (path, [t], _) when Path.same path Predef.path_list -> selfcall "list" [app (evar "List.map") [tyexpr_fun env t; x]] | Tconstr (path, [t], _) when Path.same path Predef.path_array -> diff --git a/experimental/frisch/js_syntax.ml b/experimental/frisch/js_syntax.ml index cf91aefa6b..0d65fde82a 100644 --- a/experimental/frisch/js_syntax.ml +++ b/experimental/frisch/js_syntax.ml @@ -51,7 +51,7 @@ let access_object loc e m m_typ f = let y = random_var () in let o = annot (evar y) (Typ.var obj_type) in let constr = lam (pvar y) (annot (send o m) m_typ) in - let_in [pvar x, obj; Pat.any (), constr] (f (evar x)) + let_in [Vb.mk (pvar x) obj; Vb.mk (Pat.any ()) constr] (f (evar x)) ) let method_call loc obj meth args = diff --git a/experimental/frisch/ppx_builder.ml b/experimental/frisch/ppx_builder.ml index 84491f7451..61240c1579 100644 --- a/experimental/frisch/ppx_builder.ml +++ b/experimental/frisch/ppx_builder.ml @@ -59,7 +59,7 @@ module Main : sig end = struct let fields = List.map field fields in let body = lam (punit()) (record (List.map snd fields)) in let f = List.fold_right (fun (f, _) k -> f k) fields body in - let s = Str.value Nonrecursive [pvar tdecl.ptype_name.txt, f] in + let s = Str.value Nonrecursive [Vb.mk (pvar tdecl.ptype_name.txt) f] in [s] | Ptype_variant constrs -> let constr {pcd_name={txt=name;_}; pcd_args=args; _} = @@ -67,7 +67,7 @@ module Main : sig end = struct let args = List.mapi arg args in let body = lam (punit()) (constr name (List.map (fun (_, (_, e)) -> e) args)) in let f = List.fold_right (fun (f, _) k -> f k) args body in - let s = Str.value Nonrecursive [pvar (tdecl.ptype_name.txt ^ "_" ^ name), f] in + let s = Str.value Nonrecursive [Vb.mk (pvar (tdecl.ptype_name.txt ^ "_" ^ name)) f] in s in List.map constr constrs |
