Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file ast.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135(* This file is part of the Catala compiler, a specification language for tax and social benefits
computation rules. Copyright (C) 2020 Inria, contributor: Denis Merigoux
<denis.merigoux@inria.fr>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions and limitations under
the License. *)modulePos=Utils.PosmoduleUid=Utils.Uid(** Abstract syntax tree for the default calculus *)(** {1 Abstract syntax tree} *)typetyp_lit=TBool|TUnit|TInt|TRat|TMoney|TDate|TDurationtypetyp=|TLitoftyp_lit|TTupleoftypPos.markedlist|TEnumoftypPos.markedlist|TArrowoftypPos.marked*typPos.markedtypedate=ODate.Unix.ttypeduration=Z.ttypelit=|LBoolofbool|LEmptyError|LIntofZ.t|LRatofQ.t|LMoneyofZ.t|LUnit|LDateofdate|LDurationofdurationtypeop_kind=|KInt|KRat|KMoney|KDate|KDuration(** All ops don't have a Kdate and KDuration *)typebinop=|And|Or|Addofop_kind|Subofop_kind|Multofop_kind|Divofop_kind|Ltofop_kind|Lteofop_kind|Gtofop_kind|Gteofop_kind|Eq|Neqtypelog_entry=VarDef|BeginCall|EndCalltypeunop=|Not|Minusofop_kind|ErrorOnEmpty|Logoflog_entry*Utils.Uid.MarkedString.infolisttypeoperator=Binopofbinop|Unopofunop(** The expressions use the {{:https://lepigre.fr/ocaml-bindlib/} Bindlib} library, based on
higher-order abstract syntax*)typeexpr=|EVarofexprBindlib.varPos.marked|ETupleof(exprPos.marked*Uid.MarkedString.infooption)list(** The [MarkedString.info] is the former struct field name*)|ETupleAccessofexprPos.marked*int*Uid.MarkedString.infooption(** The [MarkedString.info] is the former struct field name*)|EInjofexprPos.marked*int*Uid.MarkedString.info*typPos.markedlist(** The [MarkedString.info] is the former enum case name *)|EMatchofexprPos.marked*(exprPos.marked*Uid.MarkedString.info)list(** The [MarkedString.info] is the former enum case name *)|ELitoflit|EAbsofPos.t*(expr,exprPos.marked)Bindlib.mbinder*typPos.markedlist|EAppofexprPos.marked*exprPos.markedlist|EAssertofexprPos.marked|EOpofoperator|EDefaultofexprPos.markedlist*exprPos.marked*exprPos.marked|EIfThenElseofexprPos.marked*exprPos.marked*exprPos.marked(** {1 Variable helpers} *)moduleVar=structtypet=exprBindlib.varletmake(s:stringPos.marked):t=Bindlib.new_var(fun(x:exprBindlib.var):expr->EVar(x,Pos.get_positions))(Pos.unmarks)letcomparexy=Bindlib.compare_varsxyendmoduleVarMap=Map.Make(Var)typevars=exprBindlib.mvarletmake_var((x,pos):Var.tPos.marked):exprPos.markedBindlib.box=Bindlib.box_apply(funx->(x,pos))(Bindlib.box_varx)letmake_abs(xs:vars)(e:exprPos.markedBindlib.box)(pos_binder:Pos.t)(taus:typPos.markedlist)(pos:Pos.t):exprPos.markedBindlib.box=Bindlib.box_apply(funb->(EAbs(pos_binder,b,taus),pos))(Bindlib.bind_mvarxse)letmake_app(e:exprPos.markedBindlib.box)(u:exprPos.markedBindlib.boxlist)(pos:Pos.t):exprPos.markedBindlib.box=Bindlib.box_apply2(funeu->(EApp(e,u),pos))e(Bindlib.box_listu)letmake_let_in(x:Var.t)(tau:typPos.marked)(e1:exprPos.markedBindlib.box)(e2:exprPos.markedBindlib.box):exprPos.markedBindlib.box=Bindlib.box_apply2(funeu->(EApp(e,u),Pos.get_position(Bindlib.unboxe2)))(make_abs(Array.of_list[x])e2(Pos.get_position(Bindlib.unboxe2))[tau](Pos.get_position(Bindlib.unboxe2)))(Bindlib.box_list[e1])typebinder=(expr,exprPos.marked)Bindlib.binder