|
Packit Service |
823e34 |
(****************************************************************************)
|
|
Packit Service |
823e34 |
(* *)
|
|
Packit Service |
823e34 |
(* OCaml *)
|
|
Packit Service |
823e34 |
(* *)
|
|
Packit Service |
823e34 |
(* INRIA Rocquencourt *)
|
|
Packit Service |
823e34 |
(* *)
|
|
Packit Service |
823e34 |
(* Copyright 2006 Institut National de Recherche en Informatique et *)
|
|
Packit Service |
823e34 |
(* en Automatique. All rights reserved. This file is distributed under *)
|
|
Packit Service |
823e34 |
(* the terms of the GNU Library General Public License, with the special *)
|
|
Packit Service |
823e34 |
(* exception on linking described in LICENSE at the top of the Camlp4 *)
|
|
Packit Service |
823e34 |
(* source tree. *)
|
|
Packit Service |
823e34 |
(* *)
|
|
Packit Service |
823e34 |
(****************************************************************************)
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
(* Authors:
|
|
Packit Service |
823e34 |
* - Nicolas Pouillard: initial version
|
|
Packit Service |
823e34 |
*)
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
(** This module is suppose to contain nils elimination. *)
|
|
Packit Service |
823e34 |
module Make (Ast : Sig.Camlp4Ast) = struct
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
class clean_ast = object
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
inherit Ast.map as super;
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method with_constr wc =
|
|
Packit Service |
823e34 |
match super#with_constr wc with
|
|
Packit Service |
823e34 |
[ <:with_constr< $ <:with_constr<>> $ and $wc$ >> |
|
|
Packit Service |
823e34 |
<:with_constr< $wc$ and $ <:with_constr<>> $ >> -> wc
|
|
Packit Service |
823e34 |
| wc -> wc ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method expr e =
|
|
Packit Service |
823e34 |
match super#expr e with
|
|
Packit Service |
823e34 |
[ <:expr< let $rec:_$ $ <:binding<>> $ in $e$ >> |
|
|
Packit Service |
823e34 |
<:expr< { ($e$) with $ <:rec_binding<>> $ } >> |
|
|
Packit Service |
823e34 |
<:expr< $ <:expr<>> $, $e$ >> |
|
|
Packit Service |
823e34 |
<:expr< $e$, $ <:expr<>> $ >> |
|
|
Packit Service |
823e34 |
<:expr< $ <:expr<>> $; $e$ >> |
|
|
Packit Service |
823e34 |
<:expr< $e$; $ <:expr<>> $ >> -> e
|
|
Packit Service |
823e34 |
| e -> e ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method patt p =
|
|
Packit Service |
823e34 |
match super#patt p with
|
|
Packit Service |
823e34 |
[ <:patt< ( $p$ as $ <:patt<>> $ ) >> |
|
|
Packit Service |
823e34 |
<:patt< $ <:patt<>> $ | $p$ >> |
|
|
Packit Service |
823e34 |
<:patt< $p$ | $ <:patt<>> $ >> |
|
|
Packit Service |
823e34 |
<:patt< $ <:patt<>> $, $p$ >> |
|
|
Packit Service |
823e34 |
<:patt< $p$, $ <:patt<>> $ >> |
|
|
Packit Service |
823e34 |
<:patt< $ <:patt<>> $; $p$ >> |
|
|
Packit Service |
823e34 |
<:patt< $p$; $ <:patt<>> $ >> -> p
|
|
Packit Service |
823e34 |
| p -> p ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method match_case mc =
|
|
Packit Service |
823e34 |
match super#match_case mc with
|
|
Packit Service |
823e34 |
[ <:match_case< $ <:match_case<>> $ | $mc$ >> |
|
|
Packit Service |
823e34 |
<:match_case< $mc$ | $ <:match_case<>> $ >> -> mc
|
|
Packit Service |
823e34 |
| mc -> mc ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method binding bi =
|
|
Packit Service |
823e34 |
match super#binding bi with
|
|
Packit Service |
823e34 |
[ <:binding< $ <:binding<>> $ and $bi$ >> |
|
|
Packit Service |
823e34 |
<:binding< $bi$ and $ <:binding<>> $ >> -> bi
|
|
Packit Service |
823e34 |
| bi -> bi ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method rec_binding rb =
|
|
Packit Service |
823e34 |
match super#rec_binding rb with
|
|
Packit Service |
823e34 |
[ <:rec_binding< $ <:rec_binding<>> $ ; $bi$ >> |
|
|
Packit Service |
823e34 |
<:rec_binding< $bi$ ; $ <:rec_binding<>> $ >> -> bi
|
|
Packit Service |
823e34 |
| bi -> bi ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method module_binding mb =
|
|
Packit Service |
823e34 |
match super#module_binding mb with
|
|
Packit Service |
823e34 |
[ <:module_binding< $ <:module_binding<>> $ and $mb$ >> |
|
|
Packit Service |
823e34 |
<:module_binding< $mb$ and $ <:module_binding<>> $ >> -> mb
|
|
Packit Service |
823e34 |
| mb -> mb ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method ctyp t =
|
|
Packit Service |
823e34 |
match super#ctyp t with
|
|
Packit Service |
823e34 |
[ <:ctyp< ! $ <:ctyp<>> $ . $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $ <:ctyp<>> $ as $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$ as $ <:ctyp<>> $ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$ -> $ <:ctyp<>> $ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $ <:ctyp<>> $ -> $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $ <:ctyp<>> $ | $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$ | $ <:ctyp<>> $ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$ of $ <:ctyp<>> $ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $ <:ctyp<>> $ and $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$ and $ <:ctyp<>> $ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$; $ <:ctyp<>> $ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $ <:ctyp<>> $; $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $ <:ctyp<>> $, $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$, $ <:ctyp<>> $ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$ & $ <:ctyp<>> $ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $ <:ctyp<>> $ & $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $ <:ctyp<>> $ * $t$ >> |
|
|
Packit Service |
823e34 |
<:ctyp< $t$ * $ <:ctyp<>> $ >> -> t
|
|
Packit Service |
823e34 |
| t -> t ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method sig_item sg =
|
|
Packit Service |
823e34 |
match super#sig_item sg with
|
|
Packit Service |
823e34 |
[ <:sig_item< $ <:sig_item<>> $; $sg$ >> |
|
|
Packit Service |
823e34 |
<:sig_item< $sg$; $ <:sig_item<>> $ >> -> sg
|
|
Packit Service |
823e34 |
| Ast.SgTyp (loc, _, Ast.TyNil _) -> <:sig_item@loc<>>
|
|
Packit Service |
823e34 |
| sg -> sg ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method str_item st =
|
|
Packit Service |
823e34 |
match super#str_item st with
|
|
Packit Service |
823e34 |
[ <:str_item< $ <:str_item<>> $; $st$ >> |
|
|
Packit Service |
823e34 |
<:str_item< $st$; $ <:str_item<>> $ >> -> st
|
|
Packit Service |
823e34 |
| Ast.StTyp (loc, _, Ast.TyNil _) -> <:str_item@loc<>>
|
|
Packit Service |
823e34 |
| <:str_item@loc< value $rec:_$ $ <:binding<>> $ >> -> <:str_item@loc<>>
|
|
Packit Service |
823e34 |
| st -> st ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method module_type mt =
|
|
Packit Service |
823e34 |
match super#module_type mt with
|
|
Packit Service |
823e34 |
[ <:module_type< $mt$ with $ <:with_constr<>> $ >> -> mt
|
|
Packit Service |
823e34 |
| mt -> mt ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method class_expr ce =
|
|
Packit Service |
823e34 |
match super#class_expr ce with
|
|
Packit Service |
823e34 |
[ <:class_expr< $ <:class_expr<>> $ and $ce$ >> |
|
|
Packit Service |
823e34 |
<:class_expr< $ce$ and $ <:class_expr<>> $ >> -> ce
|
|
Packit Service |
823e34 |
| ce -> ce ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method class_type ct =
|
|
Packit Service |
823e34 |
match super#class_type ct with
|
|
Packit Service |
823e34 |
[ <:class_type< $ <:class_type<>> $ and $ct$ >> |
|
|
Packit Service |
823e34 |
<:class_type< $ct$ and $ <:class_type<>> $ >> -> ct
|
|
Packit Service |
823e34 |
| ct -> ct ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method class_sig_item csg =
|
|
Packit Service |
823e34 |
match super#class_sig_item csg with
|
|
Packit Service |
823e34 |
[ <:class_sig_item< $ <:class_sig_item<>> $; $csg$ >> |
|
|
Packit Service |
823e34 |
<:class_sig_item< $csg$; $ <:class_sig_item<>> $ >> -> csg
|
|
Packit Service |
823e34 |
| csg -> csg ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
method class_str_item cst =
|
|
Packit Service |
823e34 |
match super#class_str_item cst with
|
|
Packit Service |
823e34 |
[ <:class_str_item< $ <:class_str_item<>> $; $cst$ >> |
|
|
Packit Service |
823e34 |
<:class_str_item< $cst$; $ <:class_str_item<>> $ >> -> cst
|
|
Packit Service |
823e34 |
| cst -> cst ];
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
end;
|
|
Packit Service |
823e34 |
|
|
Packit Service |
823e34 |
end;
|