mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
refactor(runtimes): add runtime_ocaml and runtime_jsoo in the catala package
This commit is contained in:
parent
cd33ed9de7
commit
0c180e12f9
@ -7,7 +7,7 @@
|
|||||||
(library
|
(library
|
||||||
(name clerk_driver)
|
(name clerk_driver)
|
||||||
(public_name clerk.driver)
|
(public_name clerk.driver)
|
||||||
(libraries catala.runtime catala.utils ninja_utils cmdliner re ANSITerminal)
|
(libraries catala.runtime_ocaml catala.utils ninja_utils cmdliner re ANSITerminal)
|
||||||
(modules clerk_driver))
|
(modules clerk_driver))
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
[@@@ocaml.warning "-7-34"]
|
[@@@ocaml.warning "-7-34"]
|
||||||
|
|
||||||
open Utils
|
open Utils
|
||||||
|
module Runtime = Runtime_ocaml.Runtime
|
||||||
|
|
||||||
module ScopeName : Uid.Id with type info = Uid.MarkedString.info =
|
module ScopeName : Uid.Id with type info = Uid.MarkedString.info =
|
||||||
Uid.Make (Uid.MarkedString) ()
|
Uid.Make (Uid.MarkedString) ()
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
(** Abstract syntax tree of the default calculus intermediate representation *)
|
(** Abstract syntax tree of the default calculus intermediate representation *)
|
||||||
|
|
||||||
open Utils
|
open Utils
|
||||||
|
module Runtime = Runtime_ocaml.Runtime
|
||||||
module ScopeName : Uid.Id with type info = Uid.MarkedString.info
|
module ScopeName : Uid.Id with type info = Uid.MarkedString.info
|
||||||
module StructName : Uid.Id with type info = Uid.MarkedString.info
|
module StructName : Uid.Id with type info = Uid.MarkedString.info
|
||||||
module StructFieldName : Uid.Id with type info = Uid.MarkedString.info
|
module StructFieldName : Uid.Id with type info = Uid.MarkedString.info
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(library
|
(library
|
||||||
(name dcalc)
|
(name dcalc)
|
||||||
(public_name catala.dcalc)
|
(public_name catala.dcalc)
|
||||||
(libraries bindlib unionFind utils re camomile runtime)
|
(libraries bindlib unionFind utils re camomile catala.runtime_ocaml)
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps visitors.ppx)))
|
(pps visitors.ppx)))
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
open Utils
|
open Utils
|
||||||
module A = Ast
|
module A = Ast
|
||||||
|
module Runtime = Runtime_ocaml.Runtime
|
||||||
|
|
||||||
(** {1 Helpers} *)
|
(** {1 Helpers} *)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
dcalc
|
dcalc
|
||||||
lcalc
|
lcalc
|
||||||
scalc
|
scalc
|
||||||
runtime
|
catala.runtime_ocaml
|
||||||
verification)
|
verification)
|
||||||
(modules plugin driver))
|
(modules plugin driver))
|
||||||
|
|
||||||
@ -22,7 +22,11 @@
|
|||||||
(modules catala_web_interpreter)
|
(modules catala_web_interpreter)
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps js_of_ocaml-ppx))
|
(pps js_of_ocaml-ppx))
|
||||||
(libraries catala.driver js_of_ocaml))
|
(libraries
|
||||||
|
catala.driver
|
||||||
|
js_of_ocaml
|
||||||
|
catala.runtime_ocaml
|
||||||
|
catala.runtime_jsoo))
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
(name catala)
|
(name catala)
|
||||||
|
@ -106,9 +106,9 @@ Two more modules contain additional features for the compiler:
|
|||||||
{li {{: utils.html} Compiler utilities}}
|
{li {{: utils.html} Compiler utilities}}
|
||||||
}
|
}
|
||||||
|
|
||||||
The Catala runtime documentation is available here:
|
The Catala runtimes documentation is available here:
|
||||||
|
|
||||||
{!modules: Runtime}
|
{!modules: Runtime_ocaml.Runtime Runtime_jsoo.Runtime}
|
||||||
|
|
||||||
Last, it is possible to customize the backend to the compiler using a plugin
|
Last, it is possible to customize the backend to the compiler using a plugin
|
||||||
mechanism. The API is defined inside the following module:
|
mechanism. The API is defined inside the following module:
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
the License. *)
|
the License. *)
|
||||||
|
|
||||||
open Utils
|
open Utils
|
||||||
|
module Runtime = Runtime_ocaml.Runtime
|
||||||
module D = Dcalc.Ast
|
module D = Dcalc.Ast
|
||||||
|
|
||||||
type lit =
|
type lit =
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
the License. *)
|
the License. *)
|
||||||
|
|
||||||
open Utils
|
open Utils
|
||||||
|
module Runtime = Runtime_ocaml.Runtime
|
||||||
|
|
||||||
(** Abstract syntax tree for the lambda calculus *)
|
(** Abstract syntax tree for the lambda calculus *)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(library
|
(library
|
||||||
(name lcalc)
|
(name lcalc)
|
||||||
(public_name catala.lcalc)
|
(public_name catala.lcalc)
|
||||||
(libraries bindlib dcalc scopelang runtime)
|
(libraries bindlib dcalc scopelang catala.runtime_ocaml)
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps visitors.ppx)))
|
(pps visitors.ppx)))
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(library
|
(library
|
||||||
(name scalc)
|
(name scalc)
|
||||||
(public_name catala.scalc)
|
(public_name catala.scalc)
|
||||||
(libraries bindlib lcalc runtime))
|
(libraries bindlib lcalc catala.runtime_ocaml))
|
||||||
|
|
||||||
(documentation
|
(documentation
|
||||||
(package catala)
|
(package catala)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
open Utils
|
open Utils
|
||||||
open Ast
|
open Ast
|
||||||
open Lcalc.Backends
|
open Lcalc.Backends
|
||||||
|
module Runtime = Runtime_ocaml.Runtime
|
||||||
module D = Dcalc.Ast
|
module D = Dcalc.Ast
|
||||||
module L = Lcalc.Ast
|
module L = Lcalc.Ast
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
the License. *)
|
the License. *)
|
||||||
|
|
||||||
open Utils
|
open Utils
|
||||||
|
module Runtime = Runtime_ocaml.Runtime
|
||||||
|
|
||||||
(** Translation from {!module: Surface.Ast} to {!module: Desugaring.Ast}.
|
(** Translation from {!module: Surface.Ast} to {!module: Desugaring.Ast}.
|
||||||
|
|
||||||
- Removes syntactic sugars
|
- Removes syntactic sugars
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
bindlib
|
bindlib
|
||||||
utils
|
utils
|
||||||
dcalc
|
dcalc
|
||||||
runtime
|
catala.runtime_ocaml
|
||||||
calendar
|
calendar
|
||||||
(select
|
(select
|
||||||
z3backend.ml
|
z3backend.ml
|
||||||
|
4
runtimes/dune
Normal file
4
runtimes/dune
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
(dirs jsoo ocaml)
|
||||||
|
|
||||||
|
(documentation
|
||||||
|
(package catala))
|
5
runtimes/jsoo/dune
Normal file
5
runtimes/jsoo/dune
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
(library
|
||||||
|
(name runtime_jsoo)
|
||||||
|
(public_name catala.runtime_jsoo)
|
||||||
|
(libraries catala.runtime_ocaml js_of_ocaml)
|
||||||
|
(modules runtime))
|
50
runtimes/jsoo/runtime.ml
Normal file
50
runtimes/jsoo/runtime.ml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
(* This file is part of the Catala compiler, a specification language for tax
|
||||||
|
and social benefits computation rules. Copyright (C) 2020 Inria, contributor:
|
||||||
|
Emile Rolley <emile.rolley@tuta.io>.
|
||||||
|
|
||||||
|
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. *)
|
||||||
|
|
||||||
|
open Js_of_ocaml
|
||||||
|
|
||||||
|
class type source_position =
|
||||||
|
object
|
||||||
|
method fileName : Js.js_string Js.t Js.prop
|
||||||
|
method startLine : int Js.prop
|
||||||
|
method endLine : int Js.prop
|
||||||
|
method startColumn : int Js.prop
|
||||||
|
method endColumn : int Js.prop
|
||||||
|
method lawHeadings : Js.js_string Js.t Js.js_array Js.t Js.prop
|
||||||
|
end
|
||||||
|
|
||||||
|
class type raw_event =
|
||||||
|
object
|
||||||
|
method eventType : Js.js_string Js.t Js.prop
|
||||||
|
method information : Js.js_string Js.t Js.js_array Js.t Js.prop
|
||||||
|
method sourcePosition : source_position Js.t Js.optdef Js.prop
|
||||||
|
method loggedValueJson : Js.js_string Js.t Js.prop
|
||||||
|
end
|
||||||
|
|
||||||
|
class type event =
|
||||||
|
object
|
||||||
|
method data : Js.js_string Js.t Js.prop
|
||||||
|
end
|
||||||
|
|
||||||
|
class type duration =
|
||||||
|
object
|
||||||
|
method years : int Js.prop
|
||||||
|
method months : int Js.prop
|
||||||
|
method days : int Js.prop
|
||||||
|
end
|
||||||
|
|
||||||
|
(* let duration_of_jsoo d = *)
|
||||||
|
(* Runtime.duration_of_numbers d##.years d##.months d##.days *)
|
53
runtimes/jsoo/runtime.mli
Normal file
53
runtimes/jsoo/runtime.mli
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
(* This file is part of the Catala compiler, a specification language for tax
|
||||||
|
and social benefits computation rules. Copyright (C) 2020 Inria, contributor:
|
||||||
|
Emile Rolley <emile.rolley@tuta.io>.
|
||||||
|
|
||||||
|
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. *)
|
||||||
|
|
||||||
|
(** Runtime used by generated web API via
|
||||||
|
{{:http://ocsigen.org/js_of_ocaml/latest/manual/overview} [js_of_ocaml]}. *)
|
||||||
|
|
||||||
|
open Js_of_ocaml
|
||||||
|
|
||||||
|
class type source_position =
|
||||||
|
object
|
||||||
|
method fileName : Js.js_string Js.t Js.prop
|
||||||
|
method startLine : int Js.prop
|
||||||
|
method endLine : int Js.prop
|
||||||
|
method startColumn : int Js.prop
|
||||||
|
method endColumn : int Js.prop
|
||||||
|
method lawHeadings : Js.js_string Js.t Js.js_array Js.t Js.prop
|
||||||
|
end
|
||||||
|
|
||||||
|
class type raw_event =
|
||||||
|
object
|
||||||
|
method eventType : Js.js_string Js.t Js.prop
|
||||||
|
method information : Js.js_string Js.t Js.js_array Js.t Js.prop
|
||||||
|
method sourcePosition : source_position Js.t Js.optdef Js.prop
|
||||||
|
method loggedValueJson : Js.js_string Js.t Js.prop
|
||||||
|
end
|
||||||
|
|
||||||
|
class type event =
|
||||||
|
object
|
||||||
|
method data : Js.js_string Js.t Js.prop
|
||||||
|
end
|
||||||
|
|
||||||
|
class type duration =
|
||||||
|
object
|
||||||
|
method years : int Js.prop
|
||||||
|
method months : int Js.prop
|
||||||
|
method days : int Js.prop
|
||||||
|
end
|
||||||
|
|
||||||
|
(* let duration_of_jsoo d = *)
|
||||||
|
(* Runtime.duration_of_numbers d##.years d##.months d##.days *)
|
@ -1,6 +1,6 @@
|
|||||||
(library
|
(library
|
||||||
(name runtime)
|
(name runtime_ocaml)
|
||||||
(public_name catala.runtime)
|
(public_name catala.runtime_ocaml)
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps ppx_yojson_conv))
|
(pps ppx_yojson_conv))
|
||||||
(libraries calendar zarith zarith_stubs_js)
|
(libraries calendar zarith zarith_stubs_js)
|
||||||
|
@ -248,7 +248,11 @@ val date_of_numbers : int -> int -> int -> date
|
|||||||
(**{2 Durations} *)
|
(**{2 Durations} *)
|
||||||
|
|
||||||
val duration_of_numbers : int -> int -> int -> duration
|
val duration_of_numbers : int -> int -> int -> duration
|
||||||
|
(** Usage : [duration_of_numbers year mounth day]. *)
|
||||||
|
|
||||||
val duration_to_years_months_days : duration -> int * int * int
|
val duration_to_years_months_days : duration -> int * int * int
|
||||||
|
(**{2 Times} *)
|
||||||
|
|
||||||
val duration_to_string : duration -> string
|
val duration_to_string : duration -> string
|
||||||
|
|
||||||
(**{1 Defaults} *)
|
(**{1 Defaults} *)
|
||||||
|
Loading…
Reference in New Issue
Block a user