diff options
author | Nicolas Pouillard <np@nicolaspouillard.fr> | 2007-02-26 16:32:47 +0000 |
---|---|---|
committer | Nicolas Pouillard <np@nicolaspouillard.fr> | 2007-02-26 16:32:47 +0000 |
commit | 9286d93c3371194d0bae3f24c599458968f5ef76 (patch) | |
tree | 04516bbbdca4d7df89047c74011a97c73eaa1369 | |
parent | 0105c80c6aadd2de226e89c3f5f638c9afb1f01f (diff) | |
download | ocaml-9286d93c3371194d0bae3f24c599458968f5ef76.tar.gz |
[Camlp4] handle externals properly and fix the bootstrap system
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7929 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rwxr-xr-x | boot/myocamlbuild.boot | bin | 1588889 -> 1046735 bytes | |||
-rwxr-xr-x | build/camlp4-bootstrap.sh | 8 | ||||
-rwxr-xr-x | build/install.sh | 1 | ||||
-rwxr-xr-x | build/myocamlbuild.sh | 2 | ||||
-rwxr-xr-x | build/partial-install.sh | 1 | ||||
-rw-r--r-- | camlp4/Camlp4/Camlp4Ast.partial.ml | 16 | ||||
-rw-r--r-- | camlp4/Camlp4/Printers/OCaml.ml | 18 | ||||
-rw-r--r-- | camlp4/Camlp4/Sig.ml | 14 | ||||
-rw-r--r-- | camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml | 10 | ||||
-rw-r--r-- | camlp4/Camlp4Filters/Camlp4MetaGenerator.ml | 2 | ||||
-rw-r--r-- | camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml | 14 | ||||
-rw-r--r-- | camlp4/boot/Camlp4.ml | 175 | ||||
-rw-r--r-- | camlp4/boot/Camlp4.ml4 | 2 | ||||
-rw-r--r-- | camlp4/boot/Camlp4Ast.ml | 70 | ||||
-rw-r--r-- | camlp4/boot/camlp4boot.ml | 152 | ||||
-rw-r--r-- | myocamlbuild.ml | 57 |
16 files changed, 387 insertions, 155 deletions
diff --git a/boot/myocamlbuild.boot b/boot/myocamlbuild.boot Binary files differindex 9f5ac477f4..e5e8e0f90e 100755 --- a/boot/myocamlbuild.boot +++ b/boot/myocamlbuild.boot diff --git a/build/camlp4-bootstrap.sh b/build/camlp4-bootstrap.sh index 6b1b6d7fae..e1458475ee 100755 --- a/build/camlp4-bootstrap.sh +++ b/build/camlp4-bootstrap.sh @@ -6,9 +6,15 @@ TMPTARGETS="\ camlp4/boot/Lexer.ml" TARGETS="\ + camlp4/Camlp4/Struct/Camlp4Ast.ml \ camlp4/boot/Camlp4.ml \ camlp4/boot/camlp4boot.ml" +for target in $TARGETS camlp4/boot/Camlp4Ast.ml; do + [ -f "$target" ] && mv "$target" "$target.old" + rm -f "_build/$target" +done + if [ -x ./boot/myocamlbuild.native ]; then OCAMLBUILD=./boot/myocamlbuild.native else @@ -18,5 +24,5 @@ $OCAMLBUILD $TMPTARGETS $TARGETS for t in $TARGETS; do echo promote $t - cp _build/$t $t + cp _build/$t camlp4/boot/`basename $t` done diff --git a/build/install.sh b/build/install.sh index 52fe38c4af..5a640ebf60 100755 --- a/build/install.sh +++ b/build/install.sh @@ -436,6 +436,7 @@ echo "Installing camlp4..." installbin camlp4/camlp4prof.byte$EXE $BINDIR/camlp4prof$EXE installbin camlp4/mkcamlp4.byte$EXE $BINDIR/mkcamlp4$EXE installbin camlp4/camlp4.byte$EXE $BINDIR/camlp4$EXE +installbin camlp4/camlp4boot.byte$EXE $BINDIR/camlp4boot$EXE installbin camlp4/camlp4o.byte$EXE $BINDIR/camlp4o$EXE installbin camlp4/camlp4of.byte$EXE $BINDIR/camlp4of$EXE installbin camlp4/camlp4oof.byte$EXE $BINDIR/camlp4oof$EXE diff --git a/build/myocamlbuild.sh b/build/myocamlbuild.sh index a219bdce76..f75718018c 100755 --- a/build/myocamlbuild.sh +++ b/build/myocamlbuild.sh @@ -10,7 +10,7 @@ if [ ! -x _build/ocamlbuild/ocamlbuildlight.byte ]; then fi rm -rf _build/myocamlbuild boot/myocamlbuild boot/myocamlbuild.native ./boot/ocamlrun _build/ocamlbuild/ocamlbuildlight.byte -no-hygiene \ - -install-dir _build/ocamlbuild -byte-plugin -just-plugin + -tag debug -install-dir _build/ocamlbuild -byte-plugin -just-plugin cp _build/myocamlbuild boot/myocamlbuild.boot # cp boot/myocamlbuild boot/myocamlbuild.boot # rm -f boot/myocamlbuild.boot diff --git a/build/partial-install.sh b/build/partial-install.sh index f69e6f0f1f..67ee23f017 100755 --- a/build/partial-install.sh +++ b/build/partial-install.sh @@ -99,6 +99,7 @@ echo "Installing camlp4..." installbin camlp4/camlp4prof.byte$EXE $BINDIR/camlp4prof$EXE installbin camlp4/mkcamlp4.byte$EXE $BINDIR/mkcamlp4$EXE installbin camlp4/camlp4.byte$EXE $BINDIR/camlp4$EXE +installbin camlp4/camlp4boot.byte$EXE $BINDIR/camlp4boot$EXE installbin camlp4/camlp4o.byte$EXE $BINDIR/camlp4o$EXE installbin camlp4/camlp4of.byte$EXE $BINDIR/camlp4of$EXE installbin camlp4/camlp4oof.byte$EXE $BINDIR/camlp4oof$EXE diff --git a/camlp4/Camlp4/Camlp4Ast.partial.ml b/camlp4/Camlp4/Camlp4Ast.partial.ml index 295d76eec9..d9356c8e37 100644 --- a/camlp4/Camlp4/Camlp4Ast.partial.ml +++ b/camlp4/Camlp4/Camlp4Ast.partial.ml @@ -7,6 +7,10 @@ [ ONone | OSome of 'a | OAnt of string ]; + type meta_list 'a = + [ LNil + | LCons of 'a and meta_list 'a + | LAnt of string ]; type ident = [ IdAcc of Loc.t and ident and ident (* i . i *) | IdApp of Loc.t and ident and ident (* i i *) @@ -171,10 +175,8 @@ | SgDir of Loc.t and string and expr (* exception t *) | SgExc of Loc.t and ctyp - (* |+ external s : t = s ... s +| - | SgExt of Loc.t and string and ctyp and list string *) - (* external s : t = s *) - | SgExt of Loc.t and string and ctyp and string + (* external s : t = s ... s *) + | SgExt of Loc.t and string and ctyp and meta_list string (* include mt *) | SgInc of Loc.t and module_type (* module s : mt *) @@ -250,10 +252,8 @@ | StExc of Loc.t and ctyp and meta_option(*FIXME*) ident (* e *) | StExp of Loc.t and expr - (* |+ external s : t = s ... s +| - | StExt of Loc.t and string and ctyp and list string *) - (* external s : t = s *) - | StExt of Loc.t and string and ctyp and string + (* external s : t = s ... s *) + | StExt of Loc.t and string and ctyp and meta_list string (* include me *) | StInc of Loc.t and module_expr (* module s = me *) diff --git a/camlp4/Camlp4/Printers/OCaml.ml b/camlp4/Camlp4/Printers/OCaml.ml index b31c3d0100..b9cd23a918 100644 --- a/camlp4/Camlp4/Printers/OCaml.ml +++ b/camlp4/Camlp4/Printers/OCaml.ml @@ -49,6 +49,16 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct | [x] -> elt f x | [x::xs] -> do { elt f x; loop xs } ]; + value rec list_of_meta_list = + fun + [ Ast.LNil -> [] + | Ast.LCons x xs -> [x :: list_of_meta_list xs] + | Ast.LAnt x -> assert False ]; + + value meta_list elt sep f mxs = + let xs = list_of_meta_list mxs in + list elt sep f xs; + module CommentFilter = Struct.CommentFilter.Make Token; value comment_filter = CommentFilter.mk (); CommentFilter.define (Gram.get_filter ()) comment_filter; @@ -713,9 +723,9 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct do { o#sig_item f sg1; cut f; o#sig_item f sg2 } | <:sig_item< exception $t$ >> -> pp f "@[<2>exception@ %a%s@]" o#ctyp t semisep - | <:sig_item< external $s1$ : $t$ = $s2$ >> -> + | <:sig_item< external $s$ : $t$ = $sl$ >> -> pp f "@[<2>external@ %a :@ %a =@ %a%s@]" - o#var s1 o#ctyp t o#quoted_string s2 semisep + o#var s o#ctyp t (meta_list o#quoted_string "@ ") sl semisep | <:sig_item< module $s1$ ($s2$ : $mt1$) : $mt2$ >> -> let rec loop accu = fun @@ -764,9 +774,9 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct pp f "@[<2>exception@ %a%s@]" o#ctyp t semisep | <:str_item< exception $t$ = $sl$ >> -> pp f "@[<2>exception@ %a =@ %a%s@]" o#ctyp t o#ident sl semisep - | <:str_item< external $s1$ : $t$ = $s2$ >> -> + | <:str_item< external $s$ : $t$ = $sl$ >> -> pp f "@[<2>external@ %a :@ %a =@ %a%s@]" - o#var s1 o#ctyp t o#quoted_string s2 semisep + o#var s o#ctyp t (meta_list o#quoted_string "@ ") sl semisep | <:str_item< module $s1$ ($s2$ : $mt1$) = $me$ >> -> match o#module_expr_get_functor_args [(s2, mt1)] me with [ (al, me, Some mt2) -> diff --git a/camlp4/Camlp4/Sig.ml b/camlp4/Camlp4/Sig.ml index 8dd41d87d4..a9ee50e1be 100644 --- a/camlp4/Camlp4/Sig.ml +++ b/camlp4/Camlp4/Sig.ml @@ -216,6 +216,7 @@ module type Ast = sig type meta_bool = 'abstract; type meta_option 'a = 'abstract; + type meta_list 'a = 'abstract; type ctyp = 'abstract; type patt = 'abstract; type expr = 'abstract; @@ -270,6 +271,7 @@ module type Ast = sig inherit mapper; method meta_bool : meta_bool -> meta_bool; method meta_option : ! 'a 'b . ('a -> 'b) -> meta_option 'a -> meta_option 'b; + method meta_list : ! 'a 'b . ('a -> 'b) -> meta_list 'a -> meta_list 'b; method _Loc_t : Loc.t -> Loc.t; method expr : expr -> expr; method patt : patt -> patt; @@ -301,6 +303,7 @@ module type Ast = sig method ref : ! 'a . ('self_type -> 'a -> 'self_type) -> ref 'a -> 'self_type; method meta_bool : meta_bool -> 'self_type; method meta_option : ! 'a . ('self_type -> 'a -> 'self_type) -> meta_option 'a -> 'self_type; + method meta_list : ! 'a . ('self_type -> 'a -> 'self_type) -> meta_list 'a -> 'self_type; method _Loc_t : Loc.t -> 'self_type; method expr : expr -> 'self_type; method patt : patt -> 'self_type; @@ -406,10 +409,6 @@ module type Camlp4Ast = sig value meta_expr : Loc.t -> expr -> expr; value meta_ident : Loc.t -> ident -> expr; value meta_match_case : Loc.t -> match_case -> expr; - value meta_meta_bool : Loc.t -> meta_bool -> expr; - value meta_meta_option : - (Loc.t -> ident -> expr) -> - Loc.t -> meta_option ident -> expr; value meta_module_binding : Loc.t -> module_binding -> expr; value meta_module_expr : Loc.t -> module_expr -> expr; value meta_module_type : Loc.t -> module_type -> expr; @@ -434,10 +433,6 @@ module type Camlp4Ast = sig value meta_expr : Loc.t -> expr -> patt; value meta_ident : Loc.t -> ident -> patt; value meta_match_case : Loc.t -> match_case -> patt; - value meta_meta_bool : Loc.t -> meta_bool -> patt; - value meta_meta_option : - (Loc.t -> ident -> patt) -> - Loc.t -> meta_option ident -> patt; value meta_module_binding : Loc.t -> module_binding -> patt; value meta_module_expr : Loc.t -> module_expr -> patt; value meta_module_type : Loc.t -> module_type -> patt; @@ -454,6 +449,7 @@ module type Camlp4Ast = sig inherit mapper; method meta_bool : meta_bool -> meta_bool; method meta_option : ! 'a 'b . ('a -> 'b) -> meta_option 'a -> meta_option 'b; + method meta_list : ! 'a 'b . ('a -> 'b) -> meta_list 'a -> meta_list 'b; method _Loc_t : Loc.t -> Loc.t; method expr : expr -> expr; method patt : patt -> patt; @@ -486,6 +482,7 @@ module type Camlp4Ast = sig method ref : ! 'a . ('self_type -> 'a -> 'self_type) -> ref 'a -> 'self_type; method meta_bool : meta_bool -> 'self_type; method meta_option : ! 'a . ('self_type -> 'a -> 'self_type) -> meta_option 'a -> 'self_type; + method meta_list : ! 'a . ('self_type -> 'a -> 'self_type) -> meta_list 'a -> 'self_type; method _Loc_t : Loc.t -> 'self_type; method expr : expr -> 'self_type; method patt : patt -> 'self_type; @@ -591,6 +588,7 @@ module Camlp4AstToAst (M : Camlp4Ast) : Ast with module Loc = M.Loc and type meta_bool = M.meta_bool and type meta_option 'a = M.meta_option 'a + and type meta_list 'a = M.meta_list 'a and type ctyp = M.ctyp and type patt = M.patt and type expr = M.expr diff --git a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml index 02b894e799..f4881a39be 100644 --- a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml +++ b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml @@ -314,6 +314,12 @@ module Make (Ast : Sig.Camlp4Ast) = struct value mkvalue_desc t p = {pval_type = ctyp t; pval_prim = p}; + value rec list_of_meta_list = + fun + [ Ast.LNil -> [] + | Ast.LCons x xs -> [x :: list_of_meta_list xs] + | Ast.LAnt _ -> assert False ]; + value mkmutable m = if mb2b m then Mutable else Immutable; value paolab lab p = @@ -800,7 +806,7 @@ module Make (Ast : Sig.Camlp4Ast) = struct [mksig loc (Psig_exception (conv_con s) (List.map ctyp (list_of_ctyp t []))) :: l] | SgExc _ _ -> assert False (*FIXME*) - | SgExt loc n t p -> [mksig loc (Psig_value n (mkvalue_desc t [p])) :: l] + | SgExt loc n t sl -> [mksig loc (Psig_value n (mkvalue_desc t (list_of_meta_list sl))) :: l] | SgInc loc mt -> [mksig loc (Psig_include (module_type mt)) :: l] | SgMod loc n mt -> [mksig loc (Psig_module n (module_type mt)) :: l] | SgRecMod loc mb -> @@ -863,7 +869,7 @@ module Make (Ast : Sig.Camlp4Ast) = struct [mkstr loc (Pstr_exn_rebind (conv_con s) (ident i)) :: l ] | StExc _ _ _ -> assert False (*FIXME*) | StExp loc e -> [mkstr loc (Pstr_eval (expr e)) :: l] - | StExt loc n t p -> [mkstr loc (Pstr_primitive n (mkvalue_desc t [p])) :: l] + | StExt loc n t sl -> [mkstr loc (Pstr_primitive n (mkvalue_desc t (list_of_meta_list sl))) :: l] | StInc loc me -> [mkstr loc (Pstr_include (module_expr me)) :: l] | StMod loc n me -> [mkstr loc (Pstr_module n (module_expr me)) :: l] | StRecMod loc mb -> diff --git a/camlp4/Camlp4Filters/Camlp4MetaGenerator.ml b/camlp4/Camlp4Filters/Camlp4MetaGenerator.ml index a62cc8c99c..1a62e84d2c 100644 --- a/camlp4/Camlp4Filters/Camlp4MetaGenerator.ml +++ b/camlp4/Camlp4Filters/Camlp4MetaGenerator.ml @@ -91,7 +91,7 @@ value mk_meta m = let init = m_id m (meta_ident m m_name_cons) in let p = patt_of_data_ctor_decl m_name_cons tyargs in let e = - if cons = "BAnt" || cons = "OAnt" then + if cons = "BAnt" || cons = "OAnt" || cons = "LAnt" then <:expr< $id:m.ant$ _loc x0 >> else if is_antiquot_data_ctor cons then expr_of_data_ctor_decl m.ant tyargs diff --git a/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml b/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml index efdcb5b804..47a299f50d 100644 --- a/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml +++ b/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml @@ -370,8 +370,8 @@ Old (no more supported) syntax: <:str_item< exception $t$ >> | "exception"; t = constructor_declaration; "="; i = type_longident -> <:str_item< exception $t$ = $i$ >> - | "external"; i = a_LIDENT; ":"; t = ctyp; "="; s = a_STRING -> - <:str_item< external $i$ : $t$ = $s$ >> + | "external"; i = a_LIDENT; ":"; t = ctyp; "="; sl = string_list -> + <:str_item< external $i$ : $t$ = $sl$ >> | "include"; me = module_expr -> <:str_item< include $me$ >> | "module"; i = a_UIDENT; mb = module_binding0 -> <:str_item< module $i$ = $mb$ >> @@ -433,9 +433,8 @@ Old (no more supported) syntax: <:sig_item< $anti:mk_anti ~c:"sig_item" n s$ >> | "exception"; t = constructor_declaration -> <:sig_item< exception $t$ >> - (* | "external"; i = a_LIDENT; ":"; t = ctyp; "="; pd = LIST1 [ x = STRING -> x ] -> *) - | "external"; i = a_LIDENT; ":"; t = ctyp; "="; s = a_STRING -> - <:sig_item< external $i$ : $t$ = $s$ >> + | "external"; i = a_LIDENT; ":"; t = ctyp; "="; sl = string_list -> + <:sig_item< external $i$ : $t$ = $sl$ >> | "include"; mt = module_type -> <:sig_item< include $mt$ >> | "module"; i = a_UIDENT; mt = module_declaration -> <:sig_item< module $i$ : $mt$ >> @@ -1428,6 +1427,11 @@ Old (no more supported) syntax: [ [ `ANTIQUOT (""|"str"|"`str" as n) s -> mk_anti n s | `STRING _ s -> s ] ] ; + string_list: + [ [ `ANTIQUOT (""|"str_list") s -> Ast.LAnt (mk_anti "str_list" s) + | `STRING _ x; xs = string_list -> Ast.LCons x xs + | `STRING _ x -> Ast.LCons x Ast.LNil ] ] + ; value_let: [ [ "value" -> () ] ] ; diff --git a/camlp4/boot/Camlp4.ml b/camlp4/boot/Camlp4.ml index 1909430e01..59301dfbec 100644 --- a/camlp4/boot/Camlp4.ml +++ b/camlp4/boot/Camlp4.ml @@ -350,7 +350,7 @@ module Sig = sig (** The name of the extension, typically the module name. *) val name : string - (** The version of the extension, typically $Id: Id.mli,v 1.2 2006/07/08 17:21:31 pouillar Exp $ with a versionning system. *) + (** The version of the extension, typically $Id: Sig.ml,v 1.1 2007/02/07 11:41:36 ertai Exp $ with a versionning system. *) val version : string end module type Loc = @@ -489,6 +489,7 @@ module Sig = module Loc : Loc type meta_bool type 'a meta_option + type 'a meta_list type ctyp type patt type expr @@ -543,6 +544,8 @@ module Sig = method meta_bool : meta_bool -> meta_bool method meta_option : 'a 'b. ('a -> 'b) -> 'a meta_option -> 'b meta_option + method meta_list : + 'a 'b. ('a -> 'b) -> 'a meta_list -> 'b meta_list method _Loc_t : Loc.t -> Loc.t method expr : expr -> expr method patt : patt -> patt @@ -580,6 +583,10 @@ module Sig = 'a. ('self_type -> 'a -> 'self_type) -> 'a meta_option -> 'self_type + method meta_list : + 'a. + ('self_type -> 'a -> 'self_type) -> + 'a meta_list -> 'self_type method _Loc_t : Loc.t -> 'self_type method expr : expr -> 'self_type method patt : patt -> 'self_type @@ -622,6 +629,8 @@ module Sig = module Loc : Loc type meta_bool = | BTrue | BFalse | BAnt of string type 'a meta_option = | ONone | OSome of 'a | OAnt of string + type 'a meta_list = + | LNil | LCons of 'a * 'a meta_list | LAnt of string type ident = | IdAcc of Loc.t * ident * ident | (* i . i *) IdApp of Loc.t * ident * ident | (* i i *) IdLid of Loc.t * string @@ -740,9 +749,7 @@ module Sig = (* sg ; sg *) (* # s or # s e *) (* exception t *) - (* |+ external s : t = s ... s +| - | SgExt of Loc.t and string and ctyp and list string *) - (* external s : t = s *) + (* external s : t = s ... s *) (* include mt *) (* module s : mt *) (* module rec mb *) @@ -782,9 +789,7 @@ module Sig = (* exception t or exception t = i *) (*FIXME*) (* e *) - (* |+ external s : t = s ... s +| - | StExt of Loc.t and string and ctyp and list string *) - (* external s : t = s *) + (* external s : t = s ... s *) (* include me *) (* module s = me *) (* module rec mb *) @@ -867,7 +872,7 @@ module Sig = | SgClt of Loc.t * class_type | SgSem of Loc.t * sig_item * sig_item | SgDir of Loc.t * string * expr | SgExc of Loc.t * ctyp - | SgExt of Loc.t * string * ctyp * string + | SgExt of Loc.t * string * ctyp * string meta_list | SgInc of Loc.t * module_type | SgMod of Loc.t * string * module_type | SgRecMod of Loc.t * module_binding @@ -903,7 +908,7 @@ module Sig = | StSem of Loc.t * str_item * str_item | StDir of Loc.t * string * expr | StExc of Loc.t * ctyp * ident meta_option | StExp of Loc.t * expr - | StExt of Loc.t * string * ctyp * string + | StExt of Loc.t * string * ctyp * string meta_list | StInc of Loc.t * module_expr | StMod of Loc.t * string * module_expr | StRecMod of Loc.t * module_binding @@ -1007,10 +1012,6 @@ module Sig = val meta_expr : Loc.t -> expr -> expr val meta_ident : Loc.t -> ident -> expr val meta_match_case : Loc.t -> match_case -> expr - val meta_meta_bool : Loc.t -> meta_bool -> expr - val meta_meta_option : - (Loc.t -> ident -> expr) -> - Loc.t -> ident meta_option -> expr val meta_module_binding : Loc.t -> module_binding -> expr val meta_module_expr : Loc.t -> module_expr -> expr val meta_module_type : Loc.t -> module_type -> expr @@ -1037,10 +1038,6 @@ module Sig = val meta_expr : Loc.t -> expr -> patt val meta_ident : Loc.t -> ident -> patt val meta_match_case : Loc.t -> match_case -> patt - val meta_meta_bool : Loc.t -> meta_bool -> patt - val meta_meta_option : - (Loc.t -> ident -> patt) -> - Loc.t -> ident meta_option -> patt val meta_module_binding : Loc.t -> module_binding -> patt val meta_module_expr : Loc.t -> module_expr -> patt val meta_module_type : Loc.t -> module_type -> patt @@ -1057,6 +1054,8 @@ module Sig = method meta_bool : meta_bool -> meta_bool method meta_option : 'a 'b. ('a -> 'b) -> 'a meta_option -> 'b meta_option + method meta_list : + 'a 'b. ('a -> 'b) -> 'a meta_list -> 'b meta_list method _Loc_t : Loc.t -> Loc.t method expr : expr -> expr method patt : patt -> patt @@ -1094,6 +1093,10 @@ module Sig = 'a. ('self_type -> 'a -> 'self_type) -> 'a meta_option -> 'self_type + method meta_list : + 'a. + ('self_type -> 'a -> 'self_type) -> + 'a meta_list -> 'self_type method _Loc_t : Loc.t -> 'self_type method expr : expr -> 'self_type method patt : patt -> 'self_type @@ -1185,7 +1188,8 @@ module Sig = end module Camlp4AstToAst (M : Camlp4Ast) : Ast with module Loc = M.Loc and type meta_bool = M.meta_bool - and type 'a meta_option = 'a M.meta_option and type ctyp = M.ctyp + and type 'a meta_option = 'a M.meta_option + and type 'a meta_list = 'a M.meta_list and type ctyp = M.ctyp and type patt = M.patt and type expr = M.expr and type module_type = M.module_type and type sig_item = M.sig_item and type with_constr = M.with_constr @@ -1200,6 +1204,8 @@ module Sig = struct type meta_bool = | BTrue | BFalse | BAnt of string type 'a meta_option = | ONone | OSome of 'a | OAnt of string + type 'a meta_list = + | LNil | LCons of 'a * 'a meta_list | LAnt of string type ident = | IdAcc of Loc.t * ident * ident | IdApp of Loc.t * ident * ident | IdLid of Loc.t * string | IdUid of Loc.t * string @@ -1275,7 +1281,7 @@ module Sig = | SgClt of Loc.t * class_type | SgSem of Loc.t * sig_item * sig_item | SgDir of Loc.t * string * expr | SgExc of Loc.t * ctyp - | SgExt of Loc.t * string * ctyp * string + | SgExt of Loc.t * string * ctyp * string meta_list | SgInc of Loc.t * module_type | SgMod of Loc.t * string * module_type | SgRecMod of Loc.t * module_binding @@ -1311,7 +1317,7 @@ module Sig = | StSem of Loc.t * str_item * str_item | StDir of Loc.t * string * expr | StExc of Loc.t * ctyp * ident meta_option | StExp of Loc.t * expr - | StExt of Loc.t * string * ctyp * string + | StExt of Loc.t * string * ctyp * string meta_list | StInc of Loc.t * module_expr | StMod of Loc.t * string * module_expr | StRecMod of Loc.t * module_binding @@ -6339,6 +6345,21 @@ module Struct = Ast.ExId (_loc, Ast.IdAcc (_loc, Ast.IdUid (_loc, "Ast"), Ast.IdUid (_loc, "BTrue"))) + and meta_meta_list mf_a _loc = + function + | Ast.LAnt x0 -> Ast.ExAnt (_loc, x0) + | Ast.LCons (x0, x1) -> + Ast.ExApp (_loc, + Ast.ExApp (_loc, + Ast.ExId (_loc, + Ast.IdAcc (_loc, Ast.IdUid (_loc, "Ast"), + Ast.IdUid (_loc, "LCons"))), + mf_a _loc x0), + meta_meta_list mf_a _loc x1) + | Ast.LNil -> + Ast.ExId (_loc, + Ast.IdAcc (_loc, Ast.IdUid (_loc, "Ast"), + Ast.IdUid (_loc, "LNil"))) and meta_meta_option mf_a _loc = function | Ast.OAnt x0 -> Ast.ExAnt (_loc, x0) @@ -6823,7 +6844,7 @@ module Struct = meta_acc_Loc_t _loc x0), meta_string _loc x1), meta_ctyp _loc x2), - meta_string _loc x3) + meta_meta_list meta_string _loc x3) | Ast.SgExc (x0, x1) -> Ast.ExApp (_loc, Ast.ExApp (_loc, @@ -6956,7 +6977,7 @@ module Struct = meta_acc_Loc_t _loc x0), meta_string _loc x1), meta_ctyp _loc x2), - meta_string _loc x3) + meta_meta_list meta_string _loc x3) | Ast.StExp (x0, x1) -> Ast.ExApp (_loc, Ast.ExApp (_loc, @@ -8314,6 +8335,21 @@ module Struct = Ast.PaId (_loc, Ast.IdAcc (_loc, Ast.IdUid (_loc, "Ast"), Ast.IdUid (_loc, "BTrue"))) + and meta_meta_list mf_a _loc = + function + | Ast.LAnt x0 -> Ast.PaAnt (_loc, x0) + | Ast.LCons (x0, x1) -> + Ast.PaApp (_loc, + Ast.PaApp (_loc, + Ast.PaId (_loc, + Ast.IdAcc (_loc, Ast.IdUid (_loc, "Ast"), + Ast.IdUid (_loc, "LCons"))), + mf_a _loc x0), + meta_meta_list mf_a _loc x1) + | Ast.LNil -> + Ast.PaId (_loc, + Ast.IdAcc (_loc, Ast.IdUid (_loc, "Ast"), + Ast.IdUid (_loc, "LNil"))) and meta_meta_option mf_a _loc = function | Ast.OAnt x0 -> Ast.PaAnt (_loc, x0) @@ -8798,7 +8834,7 @@ module Struct = meta_acc_Loc_t _loc x0), meta_string _loc x1), meta_ctyp _loc x2), - meta_string _loc x3) + meta_meta_list meta_string _loc x3) | Ast.SgExc (x0, x1) -> Ast.PaApp (_loc, Ast.PaApp (_loc, @@ -8931,7 +8967,7 @@ module Struct = meta_acc_Loc_t _loc x0), meta_string _loc x1), meta_ctyp _loc x2), - meta_string _loc x3) + meta_meta_list meta_string _loc x3) | Ast.StExp (x0, x1) -> Ast.PaApp (_loc, Ast.PaApp (_loc, @@ -9083,7 +9119,7 @@ module Struct = | StExp (_x0, _x1) -> StExp (o#_Loc_t _x0, o#expr _x1) | StExt (_x0, _x1, _x2, _x3) -> StExt (o#_Loc_t _x0, o#string _x1, o#ctyp _x2, - o#string _x3) + o#meta_list o#string _x3) | StInc (_x0, _x1) -> StInc (o#_Loc_t _x0, o#module_expr _x1) | StMod (_x0, _x1, _x2) -> @@ -9111,7 +9147,7 @@ module Struct = | SgExc (_x0, _x1) -> SgExc (o#_Loc_t _x0, o#ctyp _x1) | SgExt (_x0, _x1, _x2, _x3) -> SgExt (o#_Loc_t _x0, o#string _x1, o#ctyp _x2, - o#string _x3) + o#meta_list o#string _x3) | SgInc (_x0, _x1) -> SgInc (o#_Loc_t _x0, o#module_type _x1) | SgMod (_x0, _x1, _x2) -> @@ -9214,6 +9250,14 @@ module Struct = | ONone -> ONone | OSome _x0 -> OSome (_f_a _x0) | OAnt _x0 -> OAnt (o#string _x0) + method meta_list : + 'a 'b. ('a -> 'b) -> 'a meta_list -> 'b meta_list = + fun _f_a -> + function + | LNil -> LNil + | LCons (_x0, _x1) -> + LCons (_f_a _x0, o#meta_list _f_a _x1) + | LAnt _x0 -> LAnt (o#string _x0) method meta_bool : meta_bool -> meta_bool = function | BTrue -> BTrue @@ -9520,7 +9564,8 @@ module Struct = (fun o -> o#ident) _x2 | StExp (_x0, _x1) -> (o#_Loc_t _x0)#expr _x1 | StExt (_x0, _x1, _x2, _x3) -> - (((o#_Loc_t _x0)#string _x1)#ctyp _x2)#string _x3 + (((o#_Loc_t _x0)#string _x1)#ctyp _x2)#meta_list + (fun o -> o#string) _x3 | StInc (_x0, _x1) -> (o#_Loc_t _x0)#module_expr _x1 | StMod (_x0, _x1, _x2) -> ((o#_Loc_t _x0)#string _x1)#module_expr _x2 @@ -9543,7 +9588,8 @@ module Struct = ((o#_Loc_t _x0)#string _x1)#expr _x2 | SgExc (_x0, _x1) -> (o#_Loc_t _x0)#ctyp _x1 | SgExt (_x0, _x1, _x2, _x3) -> - (((o#_Loc_t _x0)#string _x1)#ctyp _x2)#string _x3 + (((o#_Loc_t _x0)#string _x1)#ctyp _x2)#meta_list + (fun o -> o#string) _x3 | SgInc (_x0, _x1) -> (o#_Loc_t _x0)#module_type _x1 | SgMod (_x0, _x1, _x2) -> ((o#_Loc_t _x0)#string _x1)#module_type _x2 @@ -9638,6 +9684,16 @@ module Struct = | ONone -> o | OSome _x0 -> _f_a o _x0 | OAnt _x0 -> o#string _x0 + method meta_list : + 'a. + ('self_type -> 'a -> 'self_type) -> + 'a meta_list -> 'self_type = + fun _f_a -> + function + | LNil -> o + | LCons (_x0, _x1) -> + (_f_a o _x0)#meta_list (fun o -> _f_a o) _x1 + | LAnt _x0 -> o#string _x0 method meta_bool : meta_bool -> 'self_type = function | BTrue -> o @@ -10686,6 +10742,11 @@ module Struct = let type_decl tl cl t = type_decl tl cl (loc_of_ctyp t) None false t let mkvalue_desc t p = { pval_type = ctyp t; pval_prim = p; } + let rec list_of_meta_list = + function + | Ast.LNil -> [] + | Ast.LCons (x, xs) -> x :: (list_of_meta_list xs) + | Ast.LAnt x -> assert false let mkmutable m = if mb2b m then Mutable else Immutable let paolab lab p = match (lab, p) with @@ -11267,8 +11328,10 @@ module Struct = List.map ctyp (list_of_ctyp t [])))) :: l | SgExc (_, _) -> assert false - | SgExt (loc, n, t, p) -> - (mksig loc (Psig_value (n, mkvalue_desc t [ p ]))) :: l + | SgExt (loc, n, t, sl) -> + (mksig loc + (Psig_value (n, mkvalue_desc t (list_of_meta_list sl)))) :: + l | SgInc (loc, mt) -> (mksig loc (Psig_include (module_type mt))) :: l | SgMod (loc, n, mt) -> @@ -11349,8 +11412,11 @@ module Struct = (mkstr loc (Pstr_exn_rebind (conv_con s, ident i))) :: l | StExc (_, _, _) -> assert false | StExp (loc, e) -> (mkstr loc (Pstr_eval (expr e))) :: l - | StExt (loc, n, t, p) -> - (mkstr loc (Pstr_primitive (n, mkvalue_desc t [ p ]))) :: l + | StExt (loc, n, t, sl) -> + (mkstr loc + (Pstr_primitive (n, + mkvalue_desc t (list_of_meta_list sl)))) :: + l | StInc (loc, me) -> (mkstr loc (Pstr_include (module_expr me))) :: l | StMod (loc, n, me) -> @@ -14017,7 +14083,7 @@ module Printers = struct let name = "Camlp4Printers.DumpCamlp4Ast" let version = - "$Id: DumpCamlp4Ast.ml,v 1.4 2006/10/03 08:54:08 ertai Exp $" + "$Id: DumpCamlp4Ast.ml,v 1.5 2007/02/07 10:09:21 ertai Exp $" end module Make (Syntax : Sig.Syntax) : Sig.Printer with module Ast = Syntax.Ast = @@ -14051,7 +14117,7 @@ module Printers = struct let name = "Camlp4Printers.DumpOCamlAst" let version = - "$Id: DumpOCamlAst.ml,v 1.4 2006/10/03 08:54:08 ertai Exp $" + "$Id: DumpOCamlAst.ml,v 1.5 2007/02/07 10:09:21 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) : Sig.Printer with module Ast = Syntax.Ast = @@ -14094,7 +14160,7 @@ module Printers = struct let name = "Camlp4.Printers.Null" let version = - "$Id: Null.ml,v 1.1 2006/10/03 08:54:08 ertai Exp $" + "$Id: Null.ml,v 1.2 2007/02/07 10:09:21 ertai Exp $" end module Make (Syntax : Sig.Syntax) = struct @@ -14262,7 +14328,7 @@ module Printers = struct let name = "Camlp4.Printers.OCaml" let version = - "$Id: OCaml.ml,v 1.19 2006/10/10 22:32:43 ertai Exp $" + "$Id: OCaml.ml,v 1.20 2007/02/07 10:09:21 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) = struct @@ -14287,6 +14353,13 @@ module Printers = | [] -> () | [ x ] -> elt f x | x :: xs -> (elt f x; loop xs) + let rec list_of_meta_list = + function + | Ast.LNil -> [] + | Ast.LCons (x, xs) -> x :: (list_of_meta_list xs) + | Ast.LAnt x -> assert false + let meta_list elt sep f mxs = + let xs = list_of_meta_list mxs in list elt sep f xs module CommentFilter = Struct.CommentFilter.Make(Token) let comment_filter = CommentFilter.mk () let _ = CommentFilter.define (Gram.get_filter ()) comment_filter @@ -14724,7 +14797,8 @@ module Printers = "@[<hv0>@[<2>if@ %a@]@ @[<2>then@ %a@]@ @[<2>else@ %a@]@]" o#expr e1 o#under_semi#expr e2 o#under_semi#expr e3 - | Ast.ExLaz (_, e) -> pp f "@[<2>lazy@ %a@]" o#expr e + | Ast.ExLaz (_, e) -> + pp f "@[<2>lazy@ %a@]" o#simple_expr e | Ast.ExLet (_, r, bi, e) -> (match e with | Ast.ExLet (_, _, _, _) -> @@ -15090,9 +15164,10 @@ module Printers = (o#sig_item f sg1; cut f; o#sig_item f sg2) | Ast.SgExc (_, t) -> pp f "@[<2>exception@ %a%s@]" o#ctyp t semisep - | Ast.SgExt (_, s1, t, s2) -> - pp f "@[<2>external@ %a :@ %a =@ %a%s@]" o#var s1 - o#ctyp t o#quoted_string s2 semisep + | Ast.SgExt (_, s, t, sl) -> + pp f "@[<2>external@ %a :@ %a =@ %a%s@]" o#var s + o#ctyp t (meta_list o#quoted_string "@ ") sl + semisep | Ast.SgMod (_, s1, (Ast.MtFun (_, s2, mt1, mt2))) -> let rec loop accu = (function @@ -15130,6 +15205,7 @@ module Printers = mb semisep | Ast.SgDir (_, _, _) -> () | Ast.SgAnt (_, s) -> pp f "%a%s" o#anti s semisep + | Ast.SgExt (_, _, _, _) -> assert false method str_item = fun f st -> let () = o#node f st Ast.loc_of_str_item @@ -15145,9 +15221,10 @@ module Printers = | Ast.StExc (_, t, (Ast.OSome sl)) -> pp f "@[<2>exception@ %a =@ %a%s@]" o#ctyp t o#ident sl semisep - | Ast.StExt (_, s1, t, s2) -> - pp f "@[<2>external@ %a :@ %a =@ %a%s@]" o#var s1 - o#ctyp t o#quoted_string s2 semisep + | Ast.StExt (_, s, t, sl) -> + pp f "@[<2>external@ %a :@ %a =@ %a%s@]" o#var s + o#ctyp t (meta_list o#quoted_string "@ ") sl + semisep | Ast.StMod (_, s1, (Ast.MeFun (_, s2, mt1, me))) -> (match o#module_expr_get_functor_args [ (s2, mt1) ] me @@ -15193,7 +15270,8 @@ module Printers = mb semisep | Ast.StDir (_, _, _) -> () | Ast.StAnt (_, s) -> pp f "%a%s" o#anti s semisep - | Ast.StExc (_, _, (Ast.OAnt _)) -> assert false + | Ast.StExc (_, _, (Ast.OAnt _)) | + Ast.StExt (_, _, _, _) -> assert false method module_type = fun f mt -> let () = o#node f mt Ast.loc_of_module_type @@ -15505,7 +15583,7 @@ module Printers = struct let name = "Camlp4.Printers.OCamlr" let version = - "$Id: OCamlr.ml,v 1.16 2006/10/10 22:32:43 ertai Exp $" + "$Id: OCamlr.ml,v 1.17 2007/02/07 10:09:21 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) = struct @@ -16163,12 +16241,13 @@ module PreCast : end module MakeGram (Lexer : Sig.Lexer with module Loc = Loc) : Sig.Grammar.Static with module Loc = Loc and module Token = Lexer.Token + module MakeSyntax (U : sig end) : Sig.Syntax end = struct module Id = struct let name = "Camlp4.PreCast" - let version = "$Id: PreCast.ml,v 1.3 2006/10/02 12:59:00 ertai Exp $" + let version = "$Id: PreCast.ml,v 1.4 2007/02/07 10:09:21 ertai Exp $" end type camlp4_token = Sig.camlp4_token = @@ -16188,7 +16267,9 @@ module PreCast : module Gram = Struct.Grammar.Static.Make(Lexer) module DynLoader = Struct.DynLoader module Quotation = Struct.Quotation.Make(Ast) - module Syntax = OCamlInitSyntax.Make(Warning)(Ast)(Gram)(Quotation) + module MakeSyntax (U : sig end) = + OCamlInitSyntax.Make(Warning)(Ast)(Gram)(Quotation) + module Syntax = MakeSyntax(struct end) module AstFilters = Struct.AstFilters.Make(Ast) module MakeGram = Struct.Grammar.Static.Make module Printers = diff --git a/camlp4/boot/Camlp4.ml4 b/camlp4/boot/Camlp4.ml4 index f1ebc5f706..597f42914a 100644 --- a/camlp4/boot/Camlp4.ml4 +++ b/camlp4/boot/Camlp4.ml4 @@ -12,7 +12,7 @@ module Struct = struct sig INCLUDE "camlp4/Camlp4/Struct/Token.mli"; end = struct INCLUDE "camlp4/Camlp4/Struct/Token.ml"; end; module Lexer = struct INCLUDE "camlp4/boot/Lexer.ml"; end; - module Camlp4Ast = struct INCLUDE "camlp4/boot/Camlp4Ast.ml"; end; + module Camlp4Ast = struct INCLUDE "camlp4/Camlp4/Struct/Camlp4Ast.ml"; end; module Quotation = struct INCLUDE "camlp4/Camlp4/Struct/Quotation.ml"; end; module AstFilters = struct INCLUDE "camlp4/Camlp4/Struct/AstFilters.ml"; end; module Camlp4Ast2OCamlAst : diff --git a/camlp4/boot/Camlp4Ast.ml b/camlp4/boot/Camlp4Ast.ml index 51629568ea..91b3d51c52 100644 --- a/camlp4/boot/Camlp4Ast.ml +++ b/camlp4/boot/Camlp4Ast.ml @@ -1307,6 +1307,21 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = Ast.ExId _loc (Ast.IdAcc _loc (Ast.IdUid _loc "Ast") (Ast.IdUid _loc "BTrue")) ] + and meta_meta_list mf_a _loc = + fun + [ Ast.LAnt x0 -> Ast.ExAnt _loc x0 + | Ast.LCons x0 x1 -> + Ast.ExApp _loc + (Ast.ExApp _loc + (Ast.ExId _loc + (Ast.IdAcc _loc (Ast.IdUid _loc "Ast") + (Ast.IdUid _loc "LCons"))) + (mf_a _loc x0)) + (meta_meta_list mf_a _loc x1) + | Ast.LNil -> + Ast.ExId _loc + (Ast.IdAcc _loc (Ast.IdUid _loc "Ast") + (Ast.IdUid _loc "LNil")) ] and meta_meta_option mf_a _loc = fun [ Ast.OAnt x0 -> Ast.ExAnt _loc x0 @@ -1768,7 +1783,7 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = (meta_acc_Loc_t _loc x0)) (meta_string _loc x1)) (meta_ctyp _loc x2)) - (meta_string _loc x3) + (meta_meta_list meta_string _loc x3) | Ast.SgExc x0 x1 -> Ast.ExApp _loc (Ast.ExApp _loc @@ -1895,7 +1910,7 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = (meta_acc_Loc_t _loc x0)) (meta_string _loc x1)) (meta_ctyp _loc x2)) - (meta_string _loc x3) + (meta_meta_list meta_string _loc x3) | Ast.StExp x0 x1 -> Ast.ExApp _loc (Ast.ExApp _loc @@ -3173,6 +3188,21 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = Ast.PaId _loc (Ast.IdAcc _loc (Ast.IdUid _loc "Ast") (Ast.IdUid _loc "BTrue")) ] + and meta_meta_list mf_a _loc = + fun + [ Ast.LAnt x0 -> Ast.PaAnt _loc x0 + | Ast.LCons x0 x1 -> + Ast.PaApp _loc + (Ast.PaApp _loc + (Ast.PaId _loc + (Ast.IdAcc _loc (Ast.IdUid _loc "Ast") + (Ast.IdUid _loc "LCons"))) + (mf_a _loc x0)) + (meta_meta_list mf_a _loc x1) + | Ast.LNil -> + Ast.PaId _loc + (Ast.IdAcc _loc (Ast.IdUid _loc "Ast") + (Ast.IdUid _loc "LNil")) ] and meta_meta_option mf_a _loc = fun [ Ast.OAnt x0 -> Ast.PaAnt _loc x0 @@ -3634,7 +3664,7 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = (meta_acc_Loc_t _loc x0)) (meta_string _loc x1)) (meta_ctyp _loc x2)) - (meta_string _loc x3) + (meta_meta_list meta_string _loc x3) | Ast.SgExc x0 x1 -> Ast.PaApp _loc (Ast.PaApp _loc @@ -3761,7 +3791,7 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = (meta_acc_Loc_t _loc x0)) (meta_string _loc x1)) (meta_ctyp _loc x2)) - (meta_string _loc x3) + (meta_meta_list meta_string _loc x3) | Ast.StExp x0 x1 -> Ast.PaApp _loc (Ast.PaApp _loc @@ -3901,7 +3931,8 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = StExc (o#_Loc_t _x0) (o#ctyp _x1) (o#meta_option o#ident _x2) | StExp _x0 _x1 -> StExp (o#_Loc_t _x0) (o#expr _x1) | StExt _x0 _x1 _x2 _x3 -> - StExt (o#_Loc_t _x0) (o#string _x1) (o#ctyp _x2) (o#string _x3) + StExt (o#_Loc_t _x0) (o#string _x1) (o#ctyp _x2) + (o#meta_list o#string _x3) | StInc _x0 _x1 -> StInc (o#_Loc_t _x0) (o#module_expr _x1) | StMod _x0 _x1 _x2 -> StMod (o#_Loc_t _x0) (o#string _x1) (o#module_expr _x2) @@ -3925,7 +3956,8 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = SgDir (o#_Loc_t _x0) (o#string _x1) (o#expr _x2) | SgExc _x0 _x1 -> SgExc (o#_Loc_t _x0) (o#ctyp _x1) | SgExt _x0 _x1 _x2 _x3 -> - SgExt (o#_Loc_t _x0) (o#string _x1) (o#ctyp _x2) (o#string _x3) + SgExt (o#_Loc_t _x0) (o#string _x1) (o#ctyp _x2) + (o#meta_list o#string _x3) | SgInc _x0 _x1 -> SgInc (o#_Loc_t _x0) (o#module_type _x1) | SgMod _x0 _x1 _x2 -> SgMod (o#_Loc_t _x0) (o#string _x1) (o#module_type _x2) @@ -4019,6 +4051,13 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = [ ONone -> ONone | OSome _x0 -> OSome (_f_a _x0) | OAnt _x0 -> OAnt (o#string _x0) ]; + method meta_list : + ! 'a 'b. ('a -> 'b) -> meta_list 'a -> meta_list 'b = + fun _f_a -> + fun + [ LNil -> LNil + | LCons _x0 _x1 -> LCons (_f_a _x0) (o#meta_list _f_a _x1) + | LAnt _x0 -> LAnt (o#string _x0) ]; method meta_bool : meta_bool -> meta_bool = fun [ BTrue -> BTrue @@ -4295,7 +4334,8 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = ((o#_Loc_t _x0)#ctyp _x1)#meta_option (fun o -> o#ident) _x2 | StExp _x0 _x1 -> (o#_Loc_t _x0)#expr _x1 | StExt _x0 _x1 _x2 _x3 -> - (((o#_Loc_t _x0)#string _x1)#ctyp _x2)#string _x3 + (((o#_Loc_t _x0)#string _x1)#ctyp _x2)#meta_list + (fun o -> o#string) _x3 | StInc _x0 _x1 -> (o#_Loc_t _x0)#module_expr _x1 | StMod _x0 _x1 _x2 -> ((o#_Loc_t _x0)#string _x1)#module_expr _x2 | StRecMod _x0 _x1 -> (o#_Loc_t _x0)#module_binding _x1 @@ -4313,7 +4353,8 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = | SgDir _x0 _x1 _x2 -> ((o#_Loc_t _x0)#string _x1)#expr _x2 | SgExc _x0 _x1 -> (o#_Loc_t _x0)#ctyp _x1 | SgExt _x0 _x1 _x2 _x3 -> - (((o#_Loc_t _x0)#string _x1)#ctyp _x2)#string _x3 + (((o#_Loc_t _x0)#string _x1)#ctyp _x2)#meta_list + (fun o -> o#string) _x3 | SgInc _x0 _x1 -> (o#_Loc_t _x0)#module_type _x1 | SgMod _x0 _x1 _x2 -> ((o#_Loc_t _x0)#string _x1)#module_type _x2 | SgRecMod _x0 _x1 -> (o#_Loc_t _x0)#module_binding _x1 @@ -4390,6 +4431,14 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = [ ONone -> o | OSome _x0 -> _f_a o _x0 | OAnt _x0 -> o#string _x0 ]; + method meta_list : + ! 'a. + ('self_type -> 'a -> 'self_type) -> meta_list 'a -> 'self_type = + fun _f_a -> + fun + [ LNil -> o + | LCons _x0 _x1 -> (_f_a o _x0)#meta_list (fun o -> _f_a o) _x1 + | LAnt _x0 -> o#string _x0 ]; method meta_bool : meta_bool -> 'self_type = fun [ BTrue -> o | BFalse -> o | BAnt _x0 -> o#string _x0 ]; method match_case : match_case -> 'self_type = @@ -4651,10 +4700,7 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = | Ast.ExId _ i -> if is_module_longident i then i else error () | _ -> error () ] in - fun - [ Ast.ExId _ i -> i - | Ast.ExApp _ _ _ -> error () - | t -> self t ]; + fun [ Ast.ExId _ i -> i | Ast.ExApp _ _ _ -> error () | t -> self t ]; value ident_of_ctyp = let error () = invalid_arg "ident_of_ctyp: this type is not an identifier" in diff --git a/camlp4/boot/camlp4boot.ml b/camlp4/boot/camlp4boot.ml index 9bdb28fd5c..ba9a83a8e3 100644 --- a/camlp4/boot/camlp4boot.ml +++ b/camlp4/boot/camlp4boot.ml @@ -23,7 +23,7 @@ module R = struct let name = "Camlp4RevisedParserParser" let version = - "$Id: OCamlr.ml,v 1.12 2006/07/17 14:18:26 pouillar Exp $" + "$Id: Camlp4OCamlRevisedParser.ml,v 1.1 2007/02/07 10:09:22 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) = struct @@ -596,7 +596,42 @@ Old (no more supported) syntax: and _ = (a_INT64 : 'a_INT64 Gram.Entry.t) and _ = (a_INT32 : 'a_INT32 Gram.Entry.t) and _ = (a_INT : 'a_INT Gram.Entry.t) - and _ = (a_FLOAT : 'a_FLOAT Gram.Entry.t) + and _ = (a_FLOAT : 'a_FLOAT Gram.Entry.t) in + let grammar_entry_create = Gram.Entry.mk in + let (* sem_expr: + [ [ e1 = SELF; ";"; e2 = SELF -> <:expr< $e1$; $e2$ >> + | e = expr -> e ] ] + ; *) + (* | i = opt_label; "("; p = patt_tcon; ")" -> *) + (* <:patt< ? $i$ : ($p$) >> *) + (* <:class_type< $virtual:mv$ $lid:i$ [ $t$ ] >> *) + (* | mv = opt_virtual; i = a_LIDENT -> *) + (* Ast.CeCon (_loc, mv, Ast.IdLid (_loc, i), Ast.ONone) *) + (* <:class_type< $lid:i$ >> *) + (* [ [ "virtual"; i = a_LIDENT; "["; t = comma_type_parameter; "]" -> + <:class_type< virtual $lid:i$ [ $t$ ] >> + | "virtual"; i = a_LIDENT -> + <:class_type< virtual $lid:i$ >> + | i = a_LIDENT; "["; t = comma_type_parameter; "]" -> + <:class_type< $lid:i$ [ $t$ ] >> + | i = a_LIDENT -> <:class_type< $lid:i$ >> + ] ] + ; *) + (* "virtual"; i = a_LIDENT; "["; t = comma_type_parameter; "]" -> *) + (* <:class_expr< virtual $lid:i$ [ $t$ ] >> *) + (* | "virtual"; i = a_LIDENT -> *) + (* <:class_expr< virtual $lid:i$ >> *) (* | *) + (* <:class_expr< $virtual:mv$ $lid:i$ [ $t$ ] >> *) + (* <:class_expr< $lid:i$ [ $t$ ] >> *) + (* | mv = opt_virtual; i = a_LIDENT -> *) + (* Ast.CeCon (_loc, mv, Ast.IdLid (_loc, i), Ast.ONone) *) + (* <:class_expr< $lid:i$ >> *) + (* | i = opt_label; "("; p = ipatt_tcon; ")" -> + <:patt< ? $i$ : ($p$) >> + | i = opt_label; "("; p = ipatt_tcon; "="; e = expr; ")" -> + <:patt< ? $i$ : ($p$ = $e$) >> *) + string_list : 'string_list Gram.Entry.t = + grammar_entry_create "string_list" in (Gram.extend (module_expr : 'module_expr Gram.Entry.t) ((fun () -> @@ -789,11 +824,11 @@ Old (no more supported) syntax: Gram.Skeyword "="; Gram.Snterm (Gram.Entry.obj - (a_STRING : 'a_STRING Gram.Entry.t)) ], + (string_list : 'string_list Gram.Entry.t)) ], (Gram.Action.mk - (fun (s : 'a_STRING) _ (t : 'ctyp) _ + (fun (sl : 'string_list) _ (t : 'ctyp) _ (i : 'a_LIDENT) _ (_loc : Loc.t) -> - (Ast.StExt (_loc, i, t, s) : 'str_item)))); + (Ast.StExt (_loc, i, t, sl) : 'str_item)))); ([ Gram.Skeyword "exception"; Gram.Snterm (Gram.Entry.obj @@ -1013,8 +1048,7 @@ Old (no more supported) syntax: ((fun () -> (None, [ ((Some "top"), None, - [ ([ (* | "external"; i = a_LIDENT; ":"; t = ctyp; "="; pd = LIST1 [ x = STRING -> x ] -> *) - Gram.Skeyword "class"; Gram.Skeyword "type"; + [ ([ Gram.Skeyword "class"; Gram.Skeyword "type"; Gram.Snterm (Gram.Entry.obj (class_type_declaration : @@ -1111,11 +1145,11 @@ Old (no more supported) syntax: Gram.Skeyword "="; Gram.Snterm (Gram.Entry.obj - (a_STRING : 'a_STRING Gram.Entry.t)) ], + (string_list : 'string_list Gram.Entry.t)) ], (Gram.Action.mk - (fun (s : 'a_STRING) _ (t : 'ctyp) _ + (fun (sl : 'string_list) _ (t : 'ctyp) _ (i : 'a_LIDENT) _ (_loc : Loc.t) -> - (Ast.SgExt (_loc, i, t, s) : 'sig_item)))); + (Ast.SgExt (_loc, i, t, sl) : 'sig_item)))); ([ Gram.Skeyword "exception"; Gram.Snterm (Gram.Entry.obj @@ -2119,10 +2153,6 @@ Old (no more supported) syntax: | _ -> assert false))) ]) ])) ()); Gram.extend - (* sem_expr: - [ [ e1 = SELF; ";"; e2 = SELF -> <:expr< $e1$; $e2$ >> - | e = expr -> e ] ] - ; *) (sem_expr_for_list : 'sem_expr_for_list Gram.Entry.t) ((fun () -> (None, @@ -2574,9 +2604,7 @@ Old (no more supported) syntax: (fun (p2 : 'patt) (p1 : 'patt) (_loc : Loc.t) -> (Ast.PaApp (_loc, p1, p2) : 'patt)))) ]); ((Some "simple"), None, - [ ([ (* | i = opt_label; "("; p = patt_tcon; ")" -> *) - (* <:patt< ? $i$ : ($p$) >> *) Gram.Skeyword "?"; - Gram.Skeyword "("; + [ ([ Gram.Skeyword "?"; Gram.Skeyword "("; Gram.Snterm (Gram.Entry.obj (patt_tcon : 'patt_tcon Gram.Entry.t)); @@ -4234,29 +4262,13 @@ Old (no more supported) syntax: ot) : 'class_info_for_class_type)))) ]) ])) ()); - Gram.extend (* <:class_type< $virtual:mv$ $lid:i$ [ $t$ ] >> *) - (* | mv = opt_virtual; i = a_LIDENT -> *) - (* Ast.CeCon (_loc, mv, Ast.IdLid (_loc, i), Ast.ONone) *) - (* <:class_type< $lid:i$ >> *) - (* [ [ "virtual"; i = a_LIDENT; "["; t = comma_type_parameter; "]" -> - <:class_type< virtual $lid:i$ [ $t$ ] >> - | "virtual"; i = a_LIDENT -> - <:class_type< virtual $lid:i$ >> - | i = a_LIDENT; "["; t = comma_type_parameter; "]" -> - <:class_type< $lid:i$ [ $t$ ] >> - | i = a_LIDENT -> <:class_type< $lid:i$ >> - ] ] - ; *) + Gram.extend (class_info_for_class_expr : 'class_info_for_class_expr Gram.Entry.t) ((fun () -> (None, [ (None, None, - [ ([ (* "virtual"; i = a_LIDENT; "["; t = comma_type_parameter; "]" -> *) - (* <:class_expr< virtual $lid:i$ [ $t$ ] >> *) - (* | "virtual"; i = a_LIDENT -> *) - (* <:class_expr< virtual $lid:i$ >> *) (* | *) - Gram.Snterm + [ ([ Gram.Snterm (Gram.Entry.obj (opt_virtual : 'opt_virtual Gram.Entry.t)); Gram.Snterm @@ -4270,11 +4282,7 @@ Old (no more supported) syntax: ot) : 'class_info_for_class_expr)))) ]) ])) ()); - Gram.extend (* <:class_expr< $virtual:mv$ $lid:i$ [ $t$ ] >> *) - (* <:class_expr< $lid:i$ [ $t$ ] >> *) - (* | mv = opt_virtual; i = a_LIDENT -> *) - (* Ast.CeCon (_loc, mv, Ast.IdLid (_loc, i), Ast.ONone) *) - (* <:class_expr< $lid:i$ >> *) + Gram.extend (class_name_and_param : 'class_name_and_param Gram.Entry.t) ((fun () -> (None, @@ -5427,11 +5435,7 @@ Old (no more supported) syntax: ((fun () -> (None, [ (None, None, - [ ([ (* | i = opt_label; "("; p = ipatt_tcon; ")" -> - <:patt< ? $i$ : ($p$) >> - | i = opt_label; "("; p = ipatt_tcon; "="; e = expr; ")" -> - <:patt< ? $i$ : ($p$ = $e$) >> *) - Gram.Skeyword "?"; Gram.Skeyword "("; + [ ([ Gram.Skeyword "?"; Gram.Skeyword "("; Gram.Snterm (Gram.Entry.obj (ipatt_tcon : 'ipatt_tcon Gram.Entry.t)); @@ -6296,6 +6300,49 @@ Old (no more supported) syntax: -> (mk_anti n s : 'a_STRING) | _ -> assert false))) ]) ])) ()); + Gram.extend (string_list : 'string_list Gram.Entry.t) + ((fun () -> + (None, + [ (None, None, + [ ([ Gram.Stoken + (((function + | STRING (_, _) -> true + | _ -> false), + "STRING (_, _)")) ], + (Gram.Action.mk + (fun (__camlp4_0 : Gram.Token.t) (_loc : Loc.t) + -> + match __camlp4_0 with + | STRING (_, x) -> + (Ast.LCons (x, Ast.LNil) : 'string_list) + | _ -> assert false))); + ([ Gram.Stoken + (((function + | STRING (_, _) -> true + | _ -> false), + "STRING (_, _)")); + Gram.Sself ], + (Gram.Action.mk + (fun (xs : 'string_list) + (__camlp4_0 : Gram.Token.t) (_loc : Loc.t) -> + match __camlp4_0 with + | STRING (_, x) -> + (Ast.LCons (x, xs) : 'string_list) + | _ -> assert false))); + ([ Gram.Stoken + (((function + | ANTIQUOT (("" | "str_list"), _) -> true + | _ -> false), + "ANTIQUOT ((\"\" | \"str_list\"), _)")) ], + (Gram.Action.mk + (fun (__camlp4_0 : Gram.Token.t) (_loc : Loc.t) + -> + match __camlp4_0 with + | ANTIQUOT (("" | "str_list"), s) -> + (Ast.LAnt (mk_anti "str_list" s) : + 'string_list) + | _ -> assert false))) ]) ])) + ()); Gram.extend (value_let : 'value_let Gram.Entry.t) ((fun () -> (None, @@ -7120,7 +7167,7 @@ module Camlp4QuotationCommon = struct let name = "Camlp4QuotationCommon" let version = - "$Id: OCamlQuotationBase.ml,v 1.7 2006/10/04 16:22:54 ertai Exp $" + "$Id: Camlp4QuotationCommon.ml,v 1.1 2007/02/07 10:09:22 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) @@ -7692,7 +7739,7 @@ module Q = struct let name = "Camlp4QuotationExpander" let version = - "$Id: OCamlQuotation.ml,v 1.3 2006/07/08 17:21:32 pouillar Exp $" + "$Id: Camlp4QuotationExpander.ml,v 1.1 2007/02/07 10:09:22 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) = struct @@ -7726,7 +7773,7 @@ module Rp = struct let name = "Camlp4OCamlRevisedParserParser" let version = - "$Id: OCamlRevisedParser.ml,v 1.5 2006/07/08 18:10:10 pouillar Exp $" + "$Id: Camlp4OCamlRevisedParserParser.ml,v 1.1 2007/02/07 10:09:22 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) = struct @@ -8622,7 +8669,8 @@ module G = module Id = struct let name = "Camlp4GrammarParser" - let version = "$Id: Grammar.ml,v 1.8 2006/10/04 16:22:54 ertai Exp $" + let version = + "$Id: Camlp4GrammarParser.ml,v 1.1 2007/02/07 10:09:22 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) = struct @@ -11029,7 +11077,7 @@ module M = struct let name = "Camlp4MacroParser" let version = - "$Id: Macro.ml,v 1.2 2006/07/08 17:21:32 pouillar Exp $" + "$Id: Camlp4MacroParser.ml,v 1.1 2007/02/07 10:09:22 ertai Exp $" end (* Added statements: @@ -11645,7 +11693,7 @@ module D = struct let name = "Camlp4DebugParser" let version = - "$Id: Debug.ml,v 1.2 2006/07/08 17:21:32 pouillar Exp $" + "$Id: Camlp4DebugParser.ml,v 1.1 2007/02/07 10:09:22 ertai Exp $" end module Make (Syntax : Sig.Camlp4Syntax) = struct @@ -11841,7 +11889,7 @@ module B = * - Daniel de Rauglaudre: initial version * - Nicolas Pouillard: refactoring *) - (* $Id: Camlp4Bin.ml,v 1.12 2006/10/02 12:58:59 ertai Exp $ *) + (* $Id: Camlp4Bin.ml,v 1.13 2007/02/07 10:09:21 ertai Exp $ *) open Camlp4 open PreCast.Syntax open PreCast diff --git a/myocamlbuild.ml b/myocamlbuild.ml index fc892ad4b3..0d8435f3fc 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -695,13 +695,8 @@ let mk_camlp4 name ?unix modules bin_mods top_mods = mk_camlp4_bin name ?unix (modules @ bin_mods); mk_camlp4_top_lib name (modules @ top_mods);; -rule "camlp4: boot/Camlp4Ast.ml -> Camlp4/Struct/Camlp4Ast.ml" - ~prod:"camlp4/Camlp4/Struct/Camlp4Ast.ml" - ~dep:"camlp4/boot/Camlp4Ast.ml" - ~insert:`top - begin fun _ _ -> - cp "camlp4/boot/Camlp4Ast.ml" "camlp4/Camlp4/Struct/Camlp4Ast.ml" - end;; +copy_rule "camlp4: boot/Camlp4Ast.ml -> Camlp4/Struct/Camlp4Ast.ml" + ~insert:`top "camlp4/boot/Camlp4Ast.ml" "camlp4/Camlp4/Struct/Camlp4Ast.ml";; rule "camlp4: Camlp4/Struct/Lexer.ml -> boot/Lexer.ml" ~prod:"camlp4/boot/Lexer.ml" @@ -711,28 +706,64 @@ rule "camlp4: Camlp4/Struct/Lexer.ml -> boot/Lexer.ml" A"-printer"; A"r"; A"-o"; Px"camlp4/boot/Lexer.ml"]) end;; +module Camlp4deps = struct + let lexer = Genlex.make_lexer ["INCLUDE"; ";"; "="; ":"];; + + let rec parse strm = + match Stream.peek strm with + | None -> [] + | Some(Genlex.Kwd "INCLUDE") -> + Stream.junk strm; + begin match Stream.peek strm with + | Some(Genlex.String s) -> + Stream.junk strm; + s :: parse strm + | _ -> invalid_arg "Camlp4deps parse failure" + end + | Some _ -> + Stream.junk strm; + parse strm + + let parse_file file = + with_input_file file begin fun ic -> + let strm = Stream.of_channel ic in + parse (lexer strm) + end + + let build_deps build file = + let includes = parse_file file in + List.iter Outcome.ignore_good (build (List.map (fun i -> [i]) includes)); +end;; + rule "camlp4: ml4 -> ml" ~prod:"%.ml" ~dep:"%.ml4" - begin fun env _ -> - Cmd(S[P cold_camlp4boot; A"-impl"; P(env"%.ml4"); A"-printer"; A"o"; - A"-D"; A"OPT"; A"-o"; Px(env"%.ml")]) + begin fun env build -> + let ml4 = env "%.ml4" and ml = env "%.ml" in + Camlp4deps.build_deps build ml4; + Cmd(S[P cold_camlp4boot; A"-impl"; P ml4; A"-printer"; A"o"; + A"-D"; A"OPT"; A"-o"; Px ml]) end;; rule "camlp4: mlast -> ml" ~prod:"%.ml" - ~dep:"%.mlast" + ~deps:["%.mlast"; "camlp4/Camlp4/Camlp4Ast.partial.ml"] begin fun env _ -> + let mlast = env "%.mlast" and ml = env "%.ml" in + (* Camlp4deps.build_deps build mlast; too hard to lex *) Cmd(S[P cold_camlp4boot; A"-printer"; A"r"; A"-filter"; A"map"; A"-filter"; A"fold"; A"-filter"; A"meta"; A"-filter"; A"trash"; - A"-impl"; P(env "%.mlast"); - A"-o"; Px(env "%.ml")]) + A"-impl"; P mlast; + A"-o"; Px ml]) end;; +dep ["ocaml"; "compile"; "file:camlp4/Camlp4/Sig.ml"] + ["camlp4/Camlp4/Camlp4Ast.partial.ml"];; + mk_camlp4_bin "camlp4" [];; mk_camlp4 "camlp4boot" ~unix:false [pa_r; pa_qc; pa_q; pa_rp; pa_g; pa_macro; pa_debug] [pr_dump] [top_rprint];; |