diff options
author | Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr> | 2002-01-24 13:26:01 +0000 |
---|---|---|
committer | Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr> | 2002-01-24 13:26:01 +0000 |
commit | 5827cbc88ea41170aa5dcf64576ebc81a988824e (patch) | |
tree | 74d1c265a33a1b1d3d5193424988eaee1bed61cb /camlp4 | |
parent | 0032c482a2024b7b3ceb593a494b1a8b10794f2c (diff) |
-
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4307 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'camlp4')
-rw-r--r-- | camlp4/meta/pa_extend.ml | 39 | ||||
-rw-r--r-- | camlp4/meta/pa_r.ml | 116 | ||||
-rw-r--r-- | camlp4/meta/q_MLast.ml | 97 | ||||
-rw-r--r-- | camlp4/ocaml_src/meta/pa_extend.ml | 41 | ||||
-rw-r--r-- | camlp4/ocaml_src/meta/pa_r.ml | 136 | ||||
-rw-r--r-- | camlp4/ocaml_src/meta/q_MLast.ml | 255 |
6 files changed, 300 insertions, 384 deletions
diff --git a/camlp4/meta/pa_extend.ml b/camlp4/meta/pa_extend.ml index 61ccca877..8c8b12e3f 100644 --- a/camlp4/meta/pa_extend.ml +++ b/camlp4/meta/pa_extend.ml @@ -590,7 +590,7 @@ value is_global e = | Some gl -> List.exists (fun n -> n.tvar = e.name.tvar) gl ] ; -value text_of_entry loc gmod gl e = +value text_of_entry loc gmod e = let ent = let x = e.name in let loc = e.name.loc in @@ -601,31 +601,6 @@ value text_of_entry loc gmod gl e = [ Some pos -> <:expr< Some $pos$ >> | None -> <:expr< None >> ] in - let levels = - if quotify.val && is_global e gl && e.pos = None then - loop e.levels where rec loop = - fun - [ [] -> [] - | [level] -> - let level = - let rule = - let psymbol = - let s = - let n = "a_" ^ e.name.tvar in - let e = mk_name loc <:expr< $lid:n$ >> in - {used = []; text = TXnterm loc e None; - styp = STlid loc "ast"} - in - {pattern = Some <:patt< a >>; symbol = s} - in - {prod = [psymbol]; action = Some <:expr< a >>} - in - {(level) with rules = [rule :: level.rules]} - in - [level] - | [level :: levels] -> [level :: loop levels] ] - else e.levels - in let txt = List.fold_right (fun level txt -> @@ -645,7 +620,7 @@ value text_of_entry loc gmod gl e = <:expr< [($lab$, $ass$, $e$) :: $txt$] >> in txt) - levels <:expr< [] >> + e.levels <:expr< [] >> in (ent, pos, txt) ; @@ -656,11 +631,13 @@ value let_in_of_extend loc gmod functor_version gl el args = do { check_use nl el; let ll = + let same_tvar e n = e.name.tvar = n.tvar in List.fold_right (fun e ll -> match e.name.expr with [ <:expr< $lid:_$ >> -> - if List.exists (fun n -> e.name.tvar = n.tvar) nl then ll + if List.exists (same_tvar e) nl then ll + else if List.exists (same_tvar e) ll then ll else [e.name :: ll] | _ -> ll ]) el [] @@ -706,7 +683,7 @@ value text_of_extend loc gmod gl el f = let args = List.map (fun e -> - let (ent, pos, txt) = text_of_entry e.name.loc gmod gl e in + let (ent, pos, txt) = text_of_entry e.name.loc gmod e in let ent = <:expr< $uid:gmod$.Entry.obj $ent$ >> in let e = <:expr< ($ent$, $pos$, $txt$) >> in <:expr< let aux () = $f$ [$e$] in aux () >>) @@ -718,7 +695,7 @@ value text_of_extend loc gmod gl el f = let args = List.fold_right (fun e el -> - let (ent, pos, txt) = text_of_entry e.name.loc gmod gl e in + let (ent, pos, txt) = text_of_entry e.name.loc gmod e in let ent = <:expr< $uid:gmod$.Entry.obj $ent$ >> in let e = <:expr< ($ent$, $pos$, $txt$) >> in <:expr< [$e$ :: $el$] >>) @@ -733,7 +710,7 @@ value text_of_functorial_extend loc gmod gl el = let el = List.map (fun e -> - let (ent, pos, txt) = text_of_entry e.name.loc gmod gl e in + let (ent, pos, txt) = text_of_entry e.name.loc gmod e in let e = <:expr< $uid:gmod$.extend $ent$ $pos$ $txt$ >> in if split_ext.val then <:expr< let aux () = $e$ in aux () >> else e) el diff --git a/camlp4/meta/pa_r.ml b/camlp4/meta/pa_r.ml index 3066d68c1..a02fdb975 100644 --- a/camlp4/meta/pa_r.ml +++ b/camlp4/meta/pa_r.ml @@ -97,17 +97,8 @@ value mkumin loc f arg = <:expr< $lid:f$ $arg$ >> ] ; -value mkuminpat loc f arg = - match arg with - [ <:patt< $int:n$ >> when int_of_string n > 0 -> - let n = "-" ^ n in - <:patt< $int:n$ >> - | <:patt< $flo:n$ >> when float_of_string n > 0.0 -> - let n = "-" ^ n in - <:patt< $flo:n$ >> - | _ -> - let f = "~" ^ f in - <:patt< $lid:f$ $arg$ >> ] +value mkuminpat loc f is_int n = + if is_int then <:patt< $int:"-" ^ n$ >> else <:patt< $flo:"-" ^ n$ >> ; value mklistexp loc last = @@ -229,7 +220,8 @@ EXTEND <:module_expr< struct $list:st$ end >> ] | [ me1 = SELF; me2 = SELF -> <:module_expr< $me1$ $me2$ >> ] | [ me1 = SELF; "."; me2 = SELF -> <:module_expr< $me1$ . $me2$ >> ] - | [ i = UIDENT -> <:module_expr< $uid:i$ >> + | "simple" + [ i = UIDENT -> <:module_expr< $uid:i$ >> | "("; me = SELF; ":"; mt = module_type; ")" -> <:module_expr< ( $me$ : $mt$ ) >> | "("; me = SELF; ")" -> <:module_expr< $me$ >> ] ] @@ -275,7 +267,8 @@ EXTEND <:module_type< sig $list:sg$ end >> ] | [ m1 = SELF; m2 = SELF -> <:module_type< $m1$ $m2$ >> ] | [ m1 = SELF; "."; m2 = SELF -> <:module_type< $m1$ . $m2$ >> ] - | [ i = UIDENT -> <:module_type< $uid:i$ >> + | "simple" + [ i = UIDENT -> <:module_type< $uid:i$ >> | i = LIDENT -> <:module_type< $lid:i$ >> | "("; mt = SELF; ")" -> <:module_type< $mt$ >> ] ] ; @@ -409,27 +402,7 @@ EXTEND | "("; e = SELF; ":"; t = ctyp; ")" -> <:expr< ($e$ : $t$) >> | "("; e = SELF; ","; el = LIST1 expr SEP ","; ")" -> <:expr< ( $list:[e::el]$) >> - | "("; e = SELF; ")" -> <:expr< $e$ >> - | x = LOCATE -> - let x = - try - let i = String.index x ':' in - (int_of_string (String.sub x 0 i), - String.sub x (i + 1) (String.length x - i - 1)) - with - [ Not_found | Failure _ -> (0, x) ] - in - Pcaml.handle_expr_locate loc x - | x = QUOTATION -> - let x = - try - let i = String.index x ':' in - (String.sub x 0 i, - String.sub x (i + 1) (String.length x - i - 1)) - with - [ Not_found -> ("", x) ] - in - Pcaml.handle_expr_quotation loc x ] ] + | "("; e = SELF; ")" -> <:expr< $e$ >> ] ] ; dummy: [ [ -> () ] ] @@ -486,8 +459,8 @@ EXTEND | s = FLOAT -> <:patt< $flo:s$ >> | s = STRING -> <:patt< $str:s$ >> | s = CHAR -> <:patt< $chr:s$ >> - | "-"; s = INT -> mkuminpat loc "-" <:patt< $int:s$ >> - | "-"; s = FLOAT -> mkuminpat loc "-" <:patt< $flo:s$ >> + | "-"; s = INT -> mkuminpat loc "-" True s + | "-"; s = FLOAT -> mkuminpat loc "-" False s | "["; "]" -> <:patt< [] >> | "["; pl = LIST1 patt SEP ";"; last = OPT [ "::"; p = patt -> p ]; "]" -> @@ -500,27 +473,7 @@ EXTEND | "("; p = SELF; "as"; p2 = SELF; ")" -> <:patt< ($p$ as $p2$) >> | "("; p = SELF; ","; pl = LIST1 patt SEP ","; ")" -> <:patt< ( $list:[p::pl]$) >> - | "_" -> <:patt< _ >> - | x = LOCATE -> - let x = - try - let i = String.index x ':' in - (int_of_string (String.sub x 0 i), - String.sub x (i + 1) (String.length x - i - 1)) - with - [ Not_found | Failure _ -> (0, x) ] - in - Pcaml.handle_patt_locate loc x - | x = QUOTATION -> - let x = - try - let i = String.index x ':' in - (String.sub x 0 i, - String.sub x (i + 1) (String.length x - i - 1)) - with - [ Not_found -> ("", x) ] - in - Pcaml.handle_patt_quotation loc x ] ] + | "_" -> <:patt< _ >> ] ] ; label_patt: [ [ i = patt_label_ident; "="; p = patt -> (i, p) ] ] @@ -528,7 +481,7 @@ EXTEND patt_label_ident: [ LEFTA [ p1 = SELF; "."; p2 = SELF -> <:patt< $p1$ . $p2$ >> ] - | RIGHTA + | "simple" RIGHTA [ i = UIDENT -> <:patt< $uid:i$ >> | i = LIDENT -> <:patt< $lid:i$ >> ] ] ; @@ -610,6 +563,53 @@ EXTEND ; END; +EXTEND + expr: LEVEL "simple" + [ [ x = LOCATE -> + let x = + try + let i = String.index x ':' in + (int_of_string (String.sub x 0 i), + String.sub x (i + 1) (String.length x - i - 1)) + with + [ Not_found | Failure _ -> (0, x) ] + in + Pcaml.handle_expr_locate loc x + | x = QUOTATION -> + let x = + try + let i = String.index x ':' in + (String.sub x 0 i, + String.sub x (i + 1) (String.length x - i - 1)) + with + [ Not_found -> ("", x) ] + in + Pcaml.handle_expr_quotation loc x ] ] + ; + patt: LEVEL "simple" + [ [ x = LOCATE -> + let x = + try + let i = String.index x ':' in + (int_of_string (String.sub x 0 i), + String.sub x (i + 1) (String.length x - i - 1)) + with + [ Not_found | Failure _ -> (0, x) ] + in + Pcaml.handle_patt_locate loc x + | x = QUOTATION -> + let x = + try + let i = String.index x ':' in + (String.sub x 0 i, + String.sub x (i + 1) (String.length x - i - 1)) + with + [ Not_found -> ("", x) ] + in + Pcaml.handle_patt_quotation loc x ] ] + ; +END; + (* Objects and Classes *) EXTEND diff --git a/camlp4/meta/q_MLast.ml b/camlp4/meta/q_MLast.ml index 4cedb9bb7..3c2cb6515 100644 --- a/camlp4/meta/q_MLast.ml +++ b/camlp4/meta/q_MLast.ml @@ -86,17 +86,8 @@ value mkumin _ f arg = Node "ExApp" [Loc; Node "ExLid" [Loc; Str f]; arg] ] ; -value mkuminpat _ f arg = - match arg with - [ Node "PaInt" [Loc; Str n] when int_of_string n > 0 -> - let n = "-" ^ n in - Node "PaInt" [Loc; Str n] - | Node "PaFlo" [Loc; Str n] when float_of_string n > 0.0 -> - let n = "-" ^ n in - Node "PaFlo" [Loc; Str n] - | _ -> - let f = "~" ^ f in - Node "PaApp" [Loc; Node "PaLid" [Loc; Str f]; arg] ] +value mkuminpat _ f is_int s = + if is_int then Node "PaInt" [Loc; s] else Node "PaFlo" [Loc; s] ; value mklistexp _ last = @@ -179,16 +170,15 @@ EXTEND Node "MeStr" [Loc; st] ] | [ me1 = SELF; me2 = SELF -> Node "MeApp" [Loc; me1; me2] ] | [ me1 = SELF; "."; me2 = SELF -> Node "MeAcc" [Loc; me1; me2] ] - | [ a = a_module_expr -> a - | i = a_UIDENT -> Node "MeUid" [Loc; i] + | "simple" + [ i = a_UIDENT -> Node "MeUid" [Loc; i] | "("; me = SELF; ":"; mt = module_type; ")" -> Node "MeTyc" [Loc; me; mt] | "("; me = SELF; ")" -> me ] ] ; str_item: [ "top" - [ a = a_str_item -> a - | "declare"; st = SLIST0 [ s = str_item; ";" -> s ]; "end" -> + [ "declare"; st = SLIST0 [ s = str_item; ";" -> s ]; "end" -> Node "StDcl" [Loc; st] | "exception"; ctl = constructor_declaration; b = rebind_exn -> let (_, c, tl) = @@ -232,15 +222,14 @@ EXTEND Node "MtSig" [Loc; sg] ] | [ m1 = SELF; m2 = SELF -> Node "MtApp" [Loc; m1; m2] ] | [ m1 = SELF; "."; m2 = SELF -> Node "MtAcc" [Loc; m1; m2] ] - | [ a = a_module_type -> a - | i = a_UIDENT -> Node "MtUid" [Loc; i] + | "simple" + [ i = a_UIDENT -> Node "MtUid" [Loc; i] | i = a_LIDENT -> Node "MtLid" [Loc; i] | "("; mt = SELF; ")" -> mt ] ] ; sig_item: [ "top" - [ a = a_sig_item -> a - | "declare"; st = SLIST0 [ s = sig_item; ";" -> s ]; "end" -> + [ "declare"; st = SLIST0 [ s = sig_item; ";" -> s ]; "end" -> Node "SgDcl" [Loc; st] | "exception"; ctl = constructor_declaration -> let (_, c, tl) = @@ -412,8 +401,7 @@ EXTEND | "~-."; e = SELF -> Node "ExApp" [Loc; Node "ExLid" [Loc; Str "~-."]; e] ] | "simple" - [ a = a_expr -> a - | s = a_INT -> Node "ExInt" [Loc; s] + [ s = a_INT -> Node "ExInt" [Loc; s] | s = a_FLOAT -> Node "ExFlo" [Loc; s] | s = a_STRING -> Node "ExStr" [Loc; s] | s = a_CHAR -> Node "ExChr" [Loc; s] @@ -432,15 +420,13 @@ EXTEND | "("; e = SELF; ":"; t = ctyp; ")" -> Node "ExTyc" [Loc; e; t] | "("; e = SELF; ","; el = SLIST1 expr SEP ","; ")" -> Node "ExTup" [Loc; Cons e el] - | "("; e = SELF; ")" -> e - | "("; el = anti_list; ")" -> Node "ExTup" [Loc; el] ] ] + | "("; e = SELF; ")" -> e ] ] ; dummy: [ [ -> () ] ] ; sequence: - [ [ a = anti_list -> a - | "let"; o = SOPT "rec"; l = SLIST1 let_binding SEP "and"; + [ [ "let"; o = SOPT "rec"; l = SLIST1 let_binding SEP "and"; [ "in" | ";" ]; el = SELF -> List [Node "ExLet" [Loc; o2b o; l; mksequence loc el]] | e = expr; ";"; el = SELF -> Cons e el @@ -467,8 +453,7 @@ EXTEND ; expr_ident: [ RIGHTA - [ a = anti_ -> a - | i = a_LIDENT -> Node "ExLid" [Loc; i] + [ i = a_LIDENT -> Node "ExLid" [Loc; i] | i = a_UIDENT -> Node "ExUid" [Loc; i] | i = a_UIDENT; "."; j = SELF -> mkexprident loc i j ] ] ; @@ -488,15 +473,14 @@ EXTEND | LEFTA [ p1 = SELF; "."; p2 = SELF -> Node "PaAcc" [Loc; p1; p2] ] | "simple" - [ a = a_patt -> a - | s = a_LIDENT -> Node "PaLid" [Loc; s] + [ s = a_LIDENT -> Node "PaLid" [Loc; s] | s = a_UIDENT -> Node "PaUid" [Loc; s] | s = a_INT -> Node "PaInt" [Loc; s] | s = a_FLOAT -> Node "PaFlo" [Loc; s] | s = a_STRING -> Node "PaStr" [Loc; s] | s = a_CHAR -> Node "PaChr" [Loc; s] - | "-"; s = a_INT -> mkuminpat loc "-" (Node "PaInt" [Loc; s]) - | "-"; s = a_FLOAT -> mkuminpat loc "-" (Node "PaFlo" [Loc; s]) + | "-"; s = a_INT -> mkuminpat loc "-" True s + | "-"; s = a_FLOAT -> mkuminpat loc "-" False s | "["; "]" -> Node "PaUid" [Loc; Str "[]"] | "["; pl = SLIST1 patt SEP ";"; last = SOPT [ "::"; p = patt -> p ]; "]" -> @@ -509,7 +493,6 @@ EXTEND | "("; p = SELF; "as"; p2 = SELF; ")" -> Node "PaAli" [Loc; p; p2] | "("; p = SELF; ","; pl = SLIST1 patt SEP ","; ")" -> Node "PaTup" [Loc; Cons p pl] - | "("; pl = anti_list; ")" -> Node "PaTup" [Loc; pl] | "_" -> Node "PaAny" [Loc] ] ] ; label_patt: @@ -518,21 +501,18 @@ EXTEND patt_label_ident: [ LEFTA [ p1 = SELF; "."; p2 = SELF -> Node "PaAcc" [Loc; p1; p2] ] - | RIGHTA - [ a = anti_ -> a - | i = a_UIDENT -> Node "PaUid" [Loc; i] + | "simple" RIGHTA + [ i = a_UIDENT -> Node "PaUid" [Loc; i] | i = a_LIDENT -> Node "PaLid" [Loc; i] ] ] ; ipatt: - [ [ a = a_ipatt -> a - | "{"; lpl = SLIST1 label_ipatt SEP ";"; "}" -> Node "PaRec" [Loc; lpl] + [ [ "{"; lpl = SLIST1 label_ipatt SEP ";"; "}" -> Node "PaRec" [Loc; lpl] | "("; ")" -> Node "PaUid" [Loc; Str "()"] | "("; p = SELF; ")" -> p | "("; p = SELF; ":"; t = ctyp; ")" -> Node "PaTyc" [Loc; p; t] | "("; p = SELF; "as"; p2 = SELF; ")" -> Node "PaAli" [Loc; p; p2] | "("; p = SELF; ","; pl = SLIST1 ipatt SEP ","; ")" -> Node "PaTup" [Loc; Cons p pl] - | "("; pl = anti_list; ")" -> Node "PaTup" [Loc; pl] | s = a_LIDENT -> Node "PaLid" [Loc; s] | "_" -> Node "PaAny" [Loc] ] ] ; @@ -567,14 +547,12 @@ EXTEND | LEFTA [ t1 = SELF; "."; t2 = SELF -> Node "TyAcc" [Loc; t1; t2] ] | "simple" - [ a = a_ctyp -> a - | "'"; i = ident -> Node "TyQuo" [Loc; i] + [ "'"; i = ident -> Node "TyQuo" [Loc; i] | "_" -> Node "TyAny" [Loc] | i = a_LIDENT -> Node "TyLid" [Loc; i] | i = a_UIDENT -> Node "TyUid" [Loc; i] | "("; t = SELF; "*"; tl = SLIST1 ctyp SEP "*"; ")" -> Node "TyTup" [Loc; Cons t tl] - | "("; tl = anti_list; ")" -> Node "TyTup" [Loc; tl] | "("; t = SELF; ")" -> t | "["; cdl = SLIST0 constructor_declaration SEP "|"; "]" -> Node "TySum" [Loc; cdl] @@ -872,40 +850,53 @@ EXTEND | e = expr -> Option (Some e) | -> Option None ] ] ; - a_module_expr: + module_expr: LEVEL "simple" [ [ a = ANTIQUOT "mexp" -> antiquot "mexp" loc a | a = ANTIQUOT "" -> antiquot "" loc a ] ] ; - a_str_item: + str_item: LEVEL "top" [ [ a = ANTIQUOT "stri" -> antiquot "stri" loc a | a = ANTIQUOT "" -> antiquot "" loc a ] ] ; - a_module_type: + module_type: LEVEL "simple" [ [ a = ANTIQUOT "mtyp" -> antiquot "mtyp" loc a | a = ANTIQUOT "" -> antiquot "" loc a ] ] ; - a_sig_item: + sig_item: LEVEL "top" [ [ a = ANTIQUOT "sigi" -> antiquot "sigi" loc a | a = ANTIQUOT "" -> antiquot "" loc a ] ] ; - a_expr: + expr: LEVEL "simple" [ [ a = ANTIQUOT "exp" -> antiquot "exp" loc a | a = ANTIQUOT "" -> antiquot "" loc a - | a = ANTIQUOT "anti" -> Node "ExAnt" [Loc; antiquot "anti" loc a] ] ] + | a = ANTIQUOT "anti" -> Node "ExAnt" [Loc; antiquot "anti" loc a] + | "("; el = anti_list; ")" -> Node "ExTup" [Loc; el] ] ] ; - a_patt: + sequence: + [ [ a = ANTIQUOT "list" -> antiquot "list" loc a ] ] + ; + expr_ident: + [ [ a = ANTIQUOT -> antiquot "" loc a ] ] + ; + patt: LEVEL "simple" [ [ a = ANTIQUOT "pat" -> antiquot "pat" loc a | a = ANTIQUOT "" -> antiquot "" loc a - | a = ANTIQUOT "anti" -> Node "PaAnt" [Loc; antiquot "anti" loc a] ] ] + | a = ANTIQUOT "anti" -> Node "PaAnt" [Loc; antiquot "anti" loc a] + | "("; pl = anti_list; ")" -> Node "PaTup" [Loc; pl] ] ] ; - a_ipatt: + patt_label_ident: LEVEL "simple" + [ [ a = ANTIQUOT -> antiquot "" loc a ] ] + ; + ipatt: [ [ a = ANTIQUOT "pat" -> antiquot "pat" loc a | a = ANTIQUOT "" -> antiquot "" loc a - | a = ANTIQUOT "anti" -> Node "PaAnt" [Loc; antiquot "anti" loc a] ] ] + | a = ANTIQUOT "anti" -> Node "PaAnt" [Loc; antiquot "anti" loc a] + | "("; pl = anti_list; ")" -> Node "PaTup" [Loc; pl] ] ] ; - a_ctyp: + ctyp: LEVEL "simple" [ [ a = ANTIQUOT "typ" -> antiquot "typ" loc a - | a = ANTIQUOT "" -> antiquot "" loc a ] ] + | a = ANTIQUOT "" -> antiquot "" loc a + | "("; tl = anti_list; ")" -> Node "TyTup" [Loc; tl] ] ] ; a_mod_ident: [ [ a = ANTIQUOT -> antiquot "" loc a ] ] diff --git a/camlp4/ocaml_src/meta/pa_extend.ml b/camlp4/ocaml_src/meta/pa_extend.ml index 91a1b7e24..650e4ac71 100644 --- a/camlp4/ocaml_src/meta/pa_extend.ml +++ b/camlp4/ocaml_src/meta/pa_extend.ml @@ -1105,7 +1105,7 @@ let is_global e = | Some gl -> List.exists (fun n -> n.tvar = e.name.tvar) gl ;; -let text_of_entry loc gmod gl e = +let text_of_entry loc gmod e = let ent = let x = e.name in let loc = e.name.loc in @@ -1125,33 +1125,6 @@ let text_of_entry loc gmod gl e = Some pos -> MLast.ExApp (loc, MLast.ExUid (loc, "Some"), pos) | None -> MLast.ExUid (loc, "None") in - let levels = - if !quotify && is_global e gl && e.pos = None then - let rec loop = - function - [] -> [] - | [level] -> - let level = - let rule = - let psymbol = - let s = - let n = "a_" ^ e.name.tvar in - let e = mk_name loc (MLast.ExLid (loc, n)) in - {used = []; text = TXnterm (loc, e, None); - styp = STlid (loc, "ast")} - in - {pattern = Some (MLast.PaLid (loc, "a")); symbol = s} - in - {prod = [psymbol]; action = Some (MLast.ExLid (loc, "a"))} - in - {level with rules = rule :: level.rules} - in - [level] - | level :: levels -> level :: loop levels - in - loop e.levels - else e.levels - in let txt = List.fold_right (fun level txt -> @@ -1178,7 +1151,7 @@ let text_of_entry loc gmod gl e = txt) in txt) - levels (MLast.ExUid (loc, "[]")) + e.levels (MLast.ExUid (loc, "[]")) in ent, pos, txt ;; @@ -1188,11 +1161,13 @@ let let_in_of_extend loc gmod functor_version gl el args = Some (n1 :: _ as nl) -> check_use nl el; let ll = + let same_tvar e n = e.name.tvar = n.tvar in List.fold_right (fun e ll -> match e.name.expr with MLast.ExLid (_, _) -> - if List.exists (fun n -> e.name.tvar = n.tvar) nl then ll + if List.exists (same_tvar e) nl then ll + else if List.exists (same_tvar e) ll then ll else e.name :: ll | _ -> ll) el [] @@ -1286,7 +1261,7 @@ let text_of_extend loc gmod gl el f = let args = List.map (fun e -> - let (ent, pos, txt) = text_of_entry e.name.loc gmod gl e in + let (ent, pos, txt) = text_of_entry e.name.loc gmod e in let ent = MLast.ExApp (loc, @@ -1320,7 +1295,7 @@ let text_of_extend loc gmod gl el f = let args = List.fold_right (fun e el -> - let (ent, pos, txt) = text_of_entry e.name.loc gmod gl e in + let (ent, pos, txt) = text_of_entry e.name.loc gmod e in let ent = MLast.ExApp (loc, @@ -1346,7 +1321,7 @@ let text_of_functorial_extend loc gmod gl el = let el = List.map (fun e -> - let (ent, pos, txt) = text_of_entry e.name.loc gmod gl e in + let (ent, pos, txt) = text_of_entry e.name.loc gmod e in let e = MLast.ExApp (loc, diff --git a/camlp4/ocaml_src/meta/pa_r.ml b/camlp4/ocaml_src/meta/pa_r.ml index 86e7f0ef2..980f0f786 100644 --- a/camlp4/ocaml_src/meta/pa_r.ml +++ b/camlp4/ocaml_src/meta/pa_r.ml @@ -89,13 +89,9 @@ let mkumin loc f arg = | _ -> let f = "~" ^ f in MLast.ExApp (loc, MLast.ExLid (loc, f), arg) ;; -let mkuminpat loc f arg = - match arg with - MLast.PaInt (_, n) when int_of_string n > 0 -> - let n = "-" ^ n in MLast.PaInt (loc, n) - | MLast.PaFlo (_, n) when float_of_string n > 0.0 -> - let n = "-" ^ n in MLast.PaFlo (loc, n) - | _ -> let f = "~" ^ f in MLast.PaApp (loc, MLast.PaLid (loc, f), arg) +let mkuminpat loc f is_int n = + if is_int then MLast.PaInt (loc, ("-" ^ n)) + else MLast.PaFlo (loc, ("-" ^ n)) ;; let mklistexp loc last = @@ -368,7 +364,7 @@ Grammar.extend Gramext.action (fun (me2 : 'module_expr) _ (me1 : 'module_expr) (loc : int * int) -> (MLast.MeAcc (loc, me1, me2) : 'module_expr))]; - None, None, + Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action (fun _ (me : 'module_expr) _ (loc : int * int) -> @@ -545,7 +541,7 @@ Grammar.extend Gramext.action (fun (m2 : 'module_type) _ (m1 : 'module_type) (loc : int * int) -> (MLast.MtAcc (loc, m1, m2) : 'module_type))]; - None, None, + Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action (fun _ (mt : 'module_type) _ (loc : int * int) -> @@ -1011,33 +1007,7 @@ Grammar.extend (fun (e : 'expr) _ (loc : int * int) -> (MLast.ExApp (loc, MLast.ExLid (loc, "~-"), e) : 'expr))]; Some "simple", None, - [[Gramext.Stoken ("QUOTATION", "")], - Gramext.action - (fun (x : string) (loc : int * int) -> - (let x = - try - let i = String.index x ':' in - String.sub x 0 i, - String.sub x (i + 1) (String.length x - i - 1) - with - Not_found -> "", x - in - Pcaml.handle_expr_quotation loc x : - 'expr)); - [Gramext.Stoken ("LOCATE", "")], - Gramext.action - (fun (x : string) (loc : int * int) -> - (let x = - try - let i = String.index x ':' in - int_of_string (String.sub x 0 i), - String.sub x (i + 1) (String.length x - i - 1) - with - Not_found | Failure _ -> 0, x - in - Pcaml.handle_expr_locate loc x : - 'expr)); - [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], + [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action (fun _ (e : 'expr) _ (loc : int * int) -> (e : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.Slist1sep @@ -1258,33 +1228,7 @@ Grammar.extend (fun (p2 : 'patt) _ (p1 : 'patt) (loc : int * int) -> (MLast.PaAcc (loc, p1, p2) : 'patt))]; Some "simple", None, - [[Gramext.Stoken ("QUOTATION", "")], - Gramext.action - (fun (x : string) (loc : int * int) -> - (let x = - try - let i = String.index x ':' in - String.sub x 0 i, - String.sub x (i + 1) (String.length x - i - 1) - with - Not_found -> "", x - in - Pcaml.handle_patt_quotation loc x : - 'patt)); - [Gramext.Stoken ("LOCATE", "")], - Gramext.action - (fun (x : string) (loc : int * int) -> - (let x = - try - let i = String.index x ':' in - int_of_string (String.sub x 0 i), - String.sub x (i + 1) (String.length x - i - 1) - with - Not_found | Failure _ -> 0, x - in - Pcaml.handle_patt_locate loc x : - 'patt)); - [Gramext.Stoken ("", "_")], + [[Gramext.Stoken ("", "_")], Gramext.action (fun _ (loc : int * int) -> (MLast.PaAny loc : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.Slist1sep @@ -1348,11 +1292,11 @@ Grammar.extend [Gramext.Stoken ("", "-"); Gramext.Stoken ("FLOAT", "")], Gramext.action (fun (s : string) _ (loc : int * int) -> - (mkuminpat loc "-" (MLast.PaFlo (loc, s)) : 'patt)); + (mkuminpat loc "-" false s : 'patt)); [Gramext.Stoken ("", "-"); Gramext.Stoken ("INT", "")], Gramext.action (fun (s : string) _ (loc : int * int) -> - (mkuminpat loc "-" (MLast.PaInt (loc, s)) : 'patt)); + (mkuminpat loc "-" true s : 'patt)); [Gramext.Stoken ("CHAR", "")], Gramext.action (fun (s : string) (loc : int * int) -> @@ -1395,7 +1339,7 @@ Grammar.extend (fun (p2 : 'patt_label_ident) _ (p1 : 'patt_label_ident) (loc : int * int) -> (MLast.PaAcc (loc, p1, p2) : 'patt_label_ident))]; - None, Some Gramext.RightA, + Some "simple", Some Gramext.RightA, [[Gramext.Stoken ("LIDENT", "")], Gramext.action (fun (i : string) (loc : int * int) -> @@ -1632,6 +1576,66 @@ Grammar.extend Gramext.action (fun _ (loc : int * int) -> (true : 'direction_flag))]]]);; +Grammar.extend + [Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), + Some (Gramext.Level "simple"), + [None, None, + [[Gramext.Stoken ("QUOTATION", "")], + Gramext.action + (fun (x : string) (loc : int * int) -> + (let x = + try + let i = String.index x ':' in + String.sub x 0 i, + String.sub x (i + 1) (String.length x - i - 1) + with + Not_found -> "", x + in + Pcaml.handle_expr_quotation loc x : + 'expr)); + [Gramext.Stoken ("LOCATE", "")], + Gramext.action + (fun (x : string) (loc : int * int) -> + (let x = + try + let i = String.index x ':' in + int_of_string (String.sub x 0 i), + String.sub x (i + 1) (String.length x - i - 1) + with + Not_found | Failure _ -> 0, x + in + Pcaml.handle_expr_locate loc x : + 'expr))]]; + Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), + Some (Gramext.Level "simple"), + [None, None, + [[Gramext.Stoken ("QUOTATION", "")], + Gramext.action + (fun (x : string) (loc : int * int) -> + (let x = + try + let i = String.index x ':' in + String.sub x 0 i, + String.sub x (i + 1) (String.length x - i - 1) + with + Not_found -> "", x + in + Pcaml.handle_patt_quotation loc x : + 'patt)); + [Gramext.Stoken ("LOCATE", "")], + Gramext.action + (fun (x : string) (loc : int * int) -> + (let x = + try + let i = String.index x ':' in + int_of_string (String.sub x 0 i), + String.sub x (i + 1) (String.length x - i - 1) + with + Not_found | Failure _ -> 0, x + in + Pcaml.handle_patt_locate loc x : + 'patt))]]];; + (* Objects and Classes *) Grammar.extend diff --git a/camlp4/ocaml_src/meta/q_MLast.ml b/camlp4/ocaml_src/meta/q_MLast.ml index 1c031b8fa..519fad246 100644 --- a/camlp4/ocaml_src/meta/q_MLast.ml +++ b/camlp4/ocaml_src/meta/q_MLast.ml @@ -84,15 +84,8 @@ let mkumin _ f arg = Node ("ExApp", [Loc; Node ("ExLid", [Loc; Str f]); arg]) ;; -let mkuminpat _ f arg = - match arg with - Node ("PaInt", [Loc; Str n]) when int_of_string n > 0 -> - let n = "-" ^ n in Node ("PaInt", [Loc; Str n]) - | Node ("PaFlo", [Loc; Str n]) when float_of_string n > 0.0 -> - let n = "-" ^ n in Node ("PaFlo", [Loc; Str n]) - | _ -> - let f = "~" ^ f in - Node ("PaApp", [Loc; Node ("PaLid", [Loc; Str f]); arg]) +let mkuminpat _ f is_int s = + if is_int then Node ("PaInt", [Loc; s]) else Node ("PaFlo", [Loc; s]) ;; let mklistexp _ last = @@ -198,7 +191,6 @@ Grammar.extend and with_constr : 'with_constr Grammar.Entry.e = grammar_entry_create "with_constr" and dummy : 'dummy Grammar.Entry.e = grammar_entry_create "dummy" - and sequence : 'sequence Grammar.Entry.e = grammar_entry_create "sequence" and let_binding : 'let_binding Grammar.Entry.e = grammar_entry_create "let_binding" and fun_binding : 'fun_binding Grammar.Entry.e = @@ -207,14 +199,9 @@ Grammar.extend grammar_entry_create "match_case" and label_expr : 'label_expr Grammar.Entry.e = grammar_entry_create "label_expr" - and expr_ident : 'expr_ident Grammar.Entry.e = - grammar_entry_create "expr_ident" and fun_def : 'fun_def Grammar.Entry.e = grammar_entry_create "fun_def" and label_patt : 'label_patt Grammar.Entry.e = grammar_entry_create "label_patt" - and patt_label_ident : 'patt_label_ident Grammar.Entry.e = - grammar_entry_create "patt_label_ident" - and ipatt : 'ipatt Grammar.Entry.e = grammar_entry_create "ipatt" and label_ipatt : 'label_ipatt Grammar.Entry.e = grammar_entry_create "label_ipatt" and type_declaration : 'type_declaration Grammar.Entry.e = @@ -272,18 +259,12 @@ Grammar.extend grammar_entry_create "mutable_flag" and dir_param : 'dir_param Grammar.Entry.e = grammar_entry_create "dir_param" - and a_module_expr : 'a_module_expr Grammar.Entry.e = - grammar_entry_create "a_module_expr" - and a_str_item : 'a_str_item Grammar.Entry.e = - grammar_entry_create "a_str_item" - and a_module_type : 'a_module_type Grammar.Entry.e = - grammar_entry_create "a_module_type" - and a_sig_item : 'a_sig_item Grammar.Entry.e = - grammar_entry_create "a_sig_item" - and a_expr : 'a_expr Grammar.Entry.e = grammar_entry_create "a_expr" - and a_patt : 'a_patt Grammar.Entry.e = grammar_entry_create "a_patt" - and a_ipatt : 'a_ipatt Grammar.Entry.e = grammar_entry_create "a_ipatt" - and a_ctyp : 'a_ctyp Grammar.Entry.e = grammar_entry_create "a_ctyp" + and sequence : 'sequence Grammar.Entry.e = grammar_entry_create "sequence" + and expr_ident : 'expr_ident Grammar.Entry.e = + grammar_entry_create "expr_ident" + and patt_label_ident : 'patt_label_ident Grammar.Entry.e = + grammar_entry_create "patt_label_ident" + and ipatt : 'ipatt Grammar.Entry.e = grammar_entry_create "ipatt" and a_mod_ident : 'a_mod_ident Grammar.Entry.e = grammar_entry_create "a_mod_ident" and a_direction_flag : 'a_direction_flag Grammar.Entry.e = @@ -354,7 +335,7 @@ Grammar.extend Gramext.action (fun (me2 : 'module_expr) _ (me1 : 'module_expr) (loc : int * int) -> (Node ("MeAcc", [Loc; me1; me2]) : 'module_expr))]; - None, None, + Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action (fun _ (me : 'module_expr) _ (loc : int * int) -> @@ -371,12 +352,7 @@ Grammar.extend (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action (fun (i : 'a_UIDENT) (loc : int * int) -> - (Node ("MeUid", [Loc; i]) : 'module_expr)); - [Gramext.Snterm - (Grammar.Entry.obj - (a_module_expr : 'a_module_expr Grammar.Entry.e))], - Gramext.action - (fun (a : 'a_module_expr) (loc : int * int) -> (a : 'module_expr))]]; + (Node ("MeUid", [Loc; i]) : 'module_expr))]]; Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e), None, [Some "top", None, [[Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], @@ -493,7 +469,7 @@ Grammar.extend Tuple [xx1; xx2; xx3] -> xx1, xx2, xx3 | _ -> match () with - _ -> raise (Match_failure ("q_MLast.ml", 6092, 6108)) + _ -> raise (Match_failure ("q_MLast.ml", 5775, 5791)) in Node ("StExc", [Loc; c; tl; b]) : 'str_item)); @@ -517,11 +493,7 @@ Grammar.extend Gramext.Stoken ("", "end")], Gramext.action (fun _ (st : ast) _ (loc : int * int) -> - (Node ("StDcl", [Loc; st]) : 'str_item)); - [Gramext.Snterm - (Grammar.Entry.obj (a_str_item : 'a_str_item Grammar.Entry.e))], - Gramext.action - (fun (a : 'a_str_item) (loc : int * int) -> (a : 'str_item))]]; + (Node ("StDcl", [Loc; st]) : 'str_item))]]; Grammar.Entry.obj (rebind_exn : 'rebind_exn Grammar.Entry.e), None, [None, None, [[], Gramext.action (fun (loc : int * int) -> (List [] : 'rebind_exn)); @@ -620,7 +592,7 @@ Grammar.extend Gramext.action (fun (m2 : 'module_type) _ (m1 : 'module_type) (loc : int * int) -> (Node ("MtAcc", [Loc; m1; m2]) : 'module_type))]; - None, None, + Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action (fun _ (mt : 'module_type) _ (loc : int * int) -> @@ -634,12 +606,7 @@ Grammar.extend (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action (fun (i : 'a_UIDENT) (loc : int * int) -> - (Node ("MtUid", [Loc; i]) : 'module_type)); - [Gramext.Snterm - (Grammar.Entry.obj - (a_module_type : 'a_module_type Grammar.Entry.e))], - Gramext.action - (fun (a : 'a_module_type) (loc : int * int) -> (a : 'module_type))]]; + (Node ("MtUid", [Loc; i]) : 'module_type))]]; Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e), None, [Some "top", None, [[Gramext.Stoken ("", "value"); @@ -728,7 +695,7 @@ Grammar.extend Tuple [xx1; xx2; xx3] -> xx1, xx2, xx3 | _ -> match () with - _ -> raise (Match_failure ("q_MLast.ml", 8155, 8171)) + _ -> raise (Match_failure ("q_MLast.ml", 7794, 7810)) in Node ("SgExc", [Loc; c; tl]) : 'sig_item)); @@ -752,11 +719,7 @@ Grammar.extend Gramext.Stoken ("", "end")], Gramext.action (fun _ (st : ast) _ (loc : int * int) -> - (Node ("SgDcl", [Loc; st]) : 'sig_item)); - [Gramext.Snterm - (Grammar.Entry.obj (a_sig_item : 'a_sig_item Grammar.Entry.e))], - Gramext.action - (fun (a : 'a_sig_item) (loc : int * int) -> (a : 'sig_item))]]; + (Node ("SgDcl", [Loc; st]) : 'sig_item))]]; Grammar.Entry.obj (module_declaration : 'module_declaration Grammar.Entry.e), None, @@ -1295,14 +1258,7 @@ Grammar.extend (Node ("ExApp", [Loc; Node ("ExLid", [Loc; Str "~-"]); e]) : 'expr))]; Some "simple", None, - [[Gramext.Stoken ("", "("); - Gramext.Snterm - (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e)); - Gramext.Stoken ("", ")")], - Gramext.action - (fun _ (el : 'anti_list) _ (loc : int * int) -> - (Node ("ExTup", [Loc; el]) : 'expr)); - [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], + [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action (fun _ (e : 'expr) _ (loc : int * int) -> (e : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.srules @@ -1437,9 +1393,7 @@ Grammar.extend [Gramext.Snterm (Grammar.Entry.obj (a_INT : 'a_INT Grammar.Entry.e))], Gramext.action (fun (s : 'a_INT) (loc : int * int) -> - (Node ("ExInt", [Loc; s]) : 'expr)); - [Gramext.Snterm (Grammar.Entry.obj (a_expr : 'a_expr Grammar.Entry.e))], - Gramext.action (fun (a : 'a_expr) (loc : int * int) -> (a : 'expr))]]; + (Node ("ExInt", [Loc; s]) : 'expr))]]; Grammar.Entry.obj (dummy : 'dummy Grammar.Entry.e), None, [None, None, [[], Gramext.action (fun (loc : int * int) -> (() : 'dummy))]]; @@ -1492,11 +1446,7 @@ Grammar.extend Gramext.action (fun (el : 'sequence) _ (l : ast) (o : ast) _ (loc : int * int) -> (List [Node ("ExLet", [Loc; o2b o; l; mksequence loc el])] : - 'sequence)); - [Gramext.Snterm - (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e))], - Gramext.action - (fun (a : 'anti_list) (loc : int * int) -> (a : 'sequence))]]; + 'sequence))]]; Grammar.Entry.obj (let_binding : 'let_binding Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); @@ -1588,10 +1538,7 @@ Grammar.extend (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action (fun (i : 'a_LIDENT) (loc : int * int) -> - (Node ("ExLid", [Loc; i]) : 'expr_ident)); - [Gramext.Snterm (Grammar.Entry.obj (anti_ : 'anti_ Grammar.Entry.e))], - Gramext.action - (fun (a : 'anti_) (loc : int * int) -> (a : 'expr_ident))]]; + (Node ("ExLid", [Loc; i]) : 'expr_ident))]]; Grammar.Entry.obj (fun_def : 'fun_def Grammar.Entry.e), None, [None, Some Gramext.RightA, [[Gramext.Stoken ("", "->"); @@ -1628,13 +1575,6 @@ Grammar.extend [[Gramext.Stoken ("", "_")], Gramext.action (fun _ (loc : int * int) -> (Node ("PaAny", [Loc]) : 'patt)); - [Gramext.Stoken ("", "("); - Gramext.Snterm - (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e)); - Gramext.Stoken ("", ")")], - Gramext.action - (fun _ (pl : 'anti_list) _ (loc : int * int) -> - (Node ("PaTup", [Loc; pl]) : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.srules [[Gramext.Slist1sep @@ -1741,12 +1681,12 @@ Grammar.extend (Grammar.Entry.obj (a_FLOAT : 'a_FLOAT Grammar.Entry.e))], Gramext.action (fun (s : 'a_FLOAT) _ (loc : int * int) -> - (mkuminpat loc "-" (Node ("PaFlo", [Loc; s])) : 'patt)); + (mkuminpat loc "-" false s : 'patt)); [Gramext.Stoken ("", "-"); Gramext.Snterm (Grammar.Entry.obj (a_INT : 'a_INT Grammar.Entry.e))], Gramext.action (fun (s : 'a_INT) _ (loc : int * int) -> - (mkuminpat loc "-" (Node ("PaInt", [Loc; s])) : 'patt)); + (mkuminpat loc "-" true s : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_CHAR : 'a_CHAR Grammar.Entry.e))], Gramext.action (fun (s : 'a_CHAR) (loc : int * int) -> @@ -1774,9 +1714,7 @@ Grammar.extend (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action (fun (s : 'a_LIDENT) (loc : int * int) -> - (Node ("PaLid", [Loc; s]) : 'patt)); - [Gramext.Snterm (Grammar.Entry.obj (a_patt : 'a_patt Grammar.Entry.e))], - Gramext.action (fun (a : 'a_patt) (loc : int * int) -> (a : 'patt))]]; + (Node ("PaLid", [Loc; s]) : 'patt))]]; Grammar.Entry.obj (label_patt : 'label_patt Grammar.Entry.e), None, [None, None, [[Gramext.Snterm @@ -1795,7 +1733,7 @@ Grammar.extend (fun (p2 : 'patt_label_ident) _ (p1 : 'patt_label_ident) (loc : int * int) -> (Node ("PaAcc", [Loc; p1; p2]) : 'patt_label_ident))]; - None, Some Gramext.RightA, + Some "simple", Some Gramext.RightA, [[Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action @@ -1805,10 +1743,7 @@ Grammar.extend (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action (fun (i : 'a_UIDENT) (loc : int * int) -> - (Node ("PaUid", [Loc; i]) : 'patt_label_ident)); - [Gramext.Snterm (Grammar.Entry.obj (anti_ : 'anti_ Grammar.Entry.e))], - Gramext.action - (fun (a : 'anti_) (loc : int * int) -> (a : 'patt_label_ident))]]; + (Node ("PaUid", [Loc; i]) : 'patt_label_ident))]]; Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "_")], @@ -1819,13 +1754,6 @@ Grammar.extend Gramext.action (fun (s : 'a_LIDENT) (loc : int * int) -> (Node ("PaLid", [Loc; s]) : 'ipatt)); - [Gramext.Stoken ("", "("); - Gramext.Snterm - (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e)); - Gramext.Stoken ("", ")")], - Gramext.action - (fun _ (pl : 'anti_list) _ (loc : int * int) -> - (Node ("PaTup", [Loc; pl]) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.srules [[Gramext.Slist1sep @@ -1876,10 +1804,7 @@ Grammar.extend Gramext.Stoken ("", "}")], Gramext.action (fun _ (lpl : ast) _ (loc : int * int) -> - (Node ("PaRec", [Loc; lpl]) : 'ipatt)); - [Gramext.Snterm - (Grammar.Entry.obj (a_ipatt : 'a_ipatt Grammar.Entry.e))], - Gramext.action (fun (a : 'a_ipatt) (loc : int * int) -> (a : 'ipatt))]]; + (Node ("PaRec", [Loc; lpl]) : 'ipatt))]]; Grammar.Entry.obj (label_ipatt : 'label_ipatt Grammar.Entry.e), None, [None, None, [[Gramext.Snterm @@ -2024,13 +1949,6 @@ Grammar.extend (Node ("TySum", [Loc; cdl]) : 'ctyp)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action (fun _ (t : 'ctyp) _ (loc : int * int) -> (t : 'ctyp)); - [Gramext.Stoken ("", "("); - Gramext.Snterm - (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e)); - Gramext.Stoken ("", ")")], - Gramext.action - (fun _ (tl : 'anti_list) _ (loc : int * int) -> - (Node ("TyTup", [Loc; tl]) : 'ctyp)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", "*"); Gramext.srules [[Gramext.Slist1sep @@ -2064,9 +1982,7 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action (fun (i : 'ident) _ (loc : int * int) -> - (Node ("TyQuo", [Loc; i]) : 'ctyp)); - [Gramext.Snterm (Grammar.Entry.obj (a_ctyp : 'a_ctyp Grammar.Entry.e))], - Gramext.action (fun (a : 'a_ctyp) (loc : int * int) -> (a : 'ctyp))]]; + (Node ("TyQuo", [Loc; i]) : 'ctyp))]]; Grammar.Entry.obj (constructor_declaration : 'constructor_declaration Grammar.Entry.e), None, @@ -3291,95 +3207,148 @@ Grammar.extend (Grammar.Entry.obj (anti_opt : 'anti_opt Grammar.Entry.e))], Gramext.action (fun (a : 'anti_opt) (loc : int * int) -> (a : 'dir_param))]]; - Grammar.Entry.obj (a_module_expr : 'a_module_expr Grammar.Entry.e), None, + Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e), + Some (Gramext.Level "simple"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "" loc a : 'a_module_expr)); + (antiquot "" loc a : 'module_expr)); [Gramext.Stoken ("ANTIQUOT", "mexp")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "mexp" loc a : 'a_module_expr))]]; - Grammar.Entry.obj (a_str_item : 'a_str_item Grammar.Entry.e), None, + (antiquot "mexp" loc a : 'module_expr))]]; + Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e), + Some (Gramext.Level "top"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "" loc a : 'a_str_item)); + (antiquot "" loc a : 'str_item)); [Gramext.Stoken ("ANTIQUOT", "stri")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "stri" loc a : 'a_str_item))]]; - Grammar.Entry.obj (a_module_type : 'a_module_type Grammar.Entry.e), None, + (antiquot "stri" loc a : 'str_item))]]; + Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e), + Some (Gramext.Level "simple"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "" loc a : 'a_module_type)); + (antiquot "" loc a : 'module_type)); [Gramext.Stoken ("ANTIQUOT", "mtyp")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "mtyp" loc a : 'a_module_type))]]; - Grammar.Entry.obj (a_sig_item : 'a_sig_item Grammar.Entry.e), None, + (antiquot "mtyp" loc a : 'module_type))]]; + Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e), + Some (Gramext.Level "top"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "" loc a : 'a_sig_item)); + (antiquot "" loc a : 'sig_item)); [Gramext.Stoken ("ANTIQUOT", "sigi")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "sigi" loc a : 'a_sig_item))]]; - Grammar.Entry.obj (a_expr : 'a_expr Grammar.Entry.e), None, + (antiquot "sigi" loc a : 'sig_item))]]; + Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), + Some (Gramext.Level "simple"), [None, None, - [[Gramext.Stoken ("ANTIQUOT", "anti")], + [[Gramext.Stoken ("", "("); + Gramext.Snterm + (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e)); + Gramext.Stoken ("", ")")], + Gramext.action + (fun _ (el : 'anti_list) _ (loc : int * int) -> + (Node ("ExTup", [Loc; el]) : 'expr)); + [Gramext.Stoken ("ANTIQUOT", "anti")], Gramext.action (fun (a : string) (loc : int * int) -> - (Node ("ExAnt", [Loc; antiquot "anti" loc a]) : 'a_expr)); + (Node ("ExAnt", [Loc; antiquot "anti" loc a]) : 'expr)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'a_expr)); + (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'expr)); [Gramext.Stoken ("ANTIQUOT", "exp")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "exp" loc a : 'a_expr))]]; - Grammar.Entry.obj (a_patt : 'a_patt Grammar.Entry.e), None, + (antiquot "exp" loc a : 'expr))]]; + Grammar.Entry.obj (sequence : 'sequence Grammar.Entry.e), None, + [None, None, + [[Gramext.Stoken ("ANTIQUOT", "list")], + Gramext.action + (fun (a : string) (loc : int * int) -> + (antiquot "list" loc a : 'sequence))]]; + Grammar.Entry.obj (expr_ident : 'expr_ident Grammar.Entry.e), None, [None, None, - [[Gramext.Stoken ("ANTIQUOT", "anti")], + [[Gramext.Stoken ("ANTIQUOT", "")], + Gramext.action + (fun (a : string) (loc : int * int) -> + (antiquot "" loc a : 'expr_ident))]]; + Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), + Some (Gramext.Level "simple"), + [None, None, + [[Gramext.Stoken ("", "("); + Gramext.Snterm + (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e)); + Gramext.Stoken ("", ")")], + Gramext.action + (fun _ (pl : 'anti_list) _ (loc : int * int) -> + (Node ("PaTup", [Loc; pl]) : 'patt)); + [Gramext.Stoken ("ANTIQUOT", "anti")], Gramext.action (fun (a : string) (loc : int * int) -> - (Node ("PaAnt", [Loc; antiquot "anti" loc a]) : 'a_patt)); + (Node ("PaAnt", [Loc; antiquot "anti" loc a]) : 'patt)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'a_patt)); + (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'patt)); [Gramext.Stoken ("ANTIQUOT", "pat")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "pat" loc a : 'a_patt))]]; - Grammar.Entry.obj (a_ipatt : 'a_ipatt Grammar.Entry.e), None, + (antiquot "pat" loc a : 'patt))]]; + Grammar.Entry.obj (patt_label_ident : 'patt_label_ident Grammar.Entry.e), + Some (Gramext.Level "simple"), [None, None, - [[Gramext.Stoken ("ANTIQUOT", "anti")], + [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action (fun (a : string) (loc : int * int) -> - (Node ("PaAnt", [Loc; antiquot "anti" loc a]) : 'a_ipatt)); - [Gramext.Stoken ("ANTIQUOT", "")], + (antiquot "" loc a : 'patt_label_ident))]]; + Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e), None, + [None, None, + [[Gramext.Stoken ("", "("); + Gramext.Snterm + (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e)); + Gramext.Stoken ("", ")")], + Gramext.action + (fun _ (pl : 'anti_list) _ (loc : int * int) -> + (Node ("PaTup", [Loc; pl]) : 'ipatt)); + [Gramext.Stoken ("ANTIQUOT", "anti")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "" loc a : 'a_ipatt)); + (Node ("PaAnt", [Loc; antiquot "anti" loc a]) : 'ipatt)); + [Gramext.Stoken ("ANTIQUOT", "")], + Gramext.action + (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'ipatt)); [Gramext.Stoken ("ANTIQUOT", "pat")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "pat" loc a : 'a_ipatt))]]; - Grammar.Entry.obj (a_ctyp : 'a_ctyp Grammar.Entry.e), None, + (antiquot "pat" loc a : 'ipatt))]]; + Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), + Some (Gramext.Level "simple"), [None, None, - [[Gramext.Stoken ("ANTIQUOT", "")], + [[Gramext.Stoken ("", "("); + Gramext.Snterm + (Grammar.Entry.obj (anti_list : 'anti_list Grammar.Entry.e)); + Gramext.Stoken ("", ")")], + Gramext.action + (fun _ (tl : 'anti_list) _ (loc : int * int) -> + (Node ("TyTup", [Loc; tl]) : 'ctyp)); + [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'a_ctyp)); + (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'ctyp)); [Gramext.Stoken ("ANTIQUOT", "typ")], Gramext.action (fun (a : string) (loc : int * int) -> - (antiquot "typ" loc a : 'a_ctyp))]]; + (antiquot "typ" loc a : 'ctyp))]]; Grammar.Entry.obj (a_mod_ident : 'a_mod_ident Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], |