Denis Merigoux
01e333b833
Use dates_calc
library ( #306 )
...
This is a WIP. Current version 0.0.2 of `dates_calc` is in the process of being published, so I guess the CI should fail currently.
- [x] Test current implementation
- [x] I commented out the `duration / duration` operator, can we remove it?
- [x] Need to add support for first and last day of month
- [x] Finish porting the Z3 backend to dates_calc
2022-09-05 15:57:08 +02:00
Denis Merigoux
6130151c8e
Fix bug and typos
2022-09-05 14:50:37 +02:00
Raphaël Monat
f60cfcc435
Merge branch 'master' of github.com:CatalaLang/catala into dates_calc_lib
2022-08-30 15:14:51 +02:00
Raphaël Monat
39110f53a5
Fix missing case
2022-08-30 15:06:45 +02:00
Louis Gesbert
5bda9e98d0
Small cleanup
...
Remove unneeded types, e.g. provisions for scalc
2022-08-29 11:29:24 +02:00
Louis Gesbert
7e0d24efd2
Make all supertypes use ('a, 't) gexpr as parameter instead of naked_gexpr
2022-08-29 11:29:24 +02:00
Louis Gesbert
5e9c3d630e
Same treatment for typ
and marked_typ
2022-08-29 11:29:24 +02:00
Louis Gesbert
be58610061
Rename marked_expr -> expr, expr -> naked_expr throughout
...
Since the marked kind is used throughout, this should be more clear
2022-08-29 11:29:23 +02:00
Louis Gesbert
8f7ba5ccaf
Rename marked_gexpr -> gexpr, gexpr -> naked_gexpr
...
Since the marked kind is used throughout, this should be more clear
2022-08-29 11:29:23 +02:00
Louis Gesbert
01cc957b3b
Used shared_ast
for scopelang expressions
2022-08-26 11:31:14 +02:00
Louis Gesbert
54eee2edea
Rationalise the tuple / enum types
...
This will allow to unify with types used earlier in the
pipeline (`Scopelang.Ast.typ`).
It seems cleaner! But some areas may warrant a later clean-up, in particular
handling of options and their types in the backends, or possible name conflicts
of structs/enums with built-in types when printing.
2022-08-23 15:48:06 +02:00
Louis Gesbert
4caf828e48
Additional cleanup/fixes on the compiler refactoring
...
following review ^^
2022-08-23 00:13:02 +02:00
Louis Gesbert
576e0fb3ff
Factorise AST printers
...
Note that there were significant differences between the two printers (see the test diff!). Overall the `dcalc` one seemed newer so that's what I took, with only the required additions from `lcalc` (exceptions, raise and catch)
2022-08-22 19:28:27 +02:00
Louis Gesbert
ae2801be6d
Move mode handling code from dcalc to shared_ast
...
Handling code should now be reasonably well sorted between `Shared_ast.{Var,Expr,Scope,Program}`
The function parameters (e.g. `make_let_in`) could be removed from the
scope handling functions since now the types are compatible, which
makes them much easier to read.
2022-08-22 19:28:27 +02:00
Louis Gesbert
8e7f65d204
Split Shared_ast.Expr of scope and program functions
2022-08-22 19:28:27 +02:00
Louis Gesbert
4bb49c14f1
Simplify some type aliases
2022-08-22 19:28:27 +02:00
Louis Gesbert
06dbab74d2
reformat
2022-08-22 19:28:27 +02:00
Louis Gesbert
2b6ee8dd4b
Leverage the shared AST: big cleanup (part I)
2022-08-22 19:28:21 +02:00
Louis Gesbert
988e5eff1c
Split the shared AST into a separate lib
2022-08-22 19:16:28 +02:00
Denis Merigoux
755b1212a2
Remove division durations
2022-08-19 15:21:29 +02:00
Denis Merigoux
e5aed3efcb
Merge branch 'master' into rmonat_dates_calc_lib
2022-08-19 14:59:46 +02:00
Denis Merigoux
b5c4608ce1
Message
2022-08-19 14:43:56 +02:00
Raphaël Monat
0b73fbbac4
Add support for first and last day of month operators
2022-08-18 21:22:50 +02:00
Denis Merigoux
437be673ce
Merge branch 'master' into aides_logement
2022-08-16 14:25:06 +02:00
Denis Merigoux
1aeb47effd
Fix uncaught type error
2022-08-15 16:20:31 +02:00
Louis Gesbert
0b0e774d1c
More factorisation, in particular for variables
2022-08-12 17:18:06 +02:00
Louis Gesbert
ebf97a0995
Pass-specific literals
2022-08-12 16:55:32 +02:00
Louis Gesbert
b5579cde3d
Generalise the expressions between dcalc and lcalc
...
The huge benefit of this approach is that almost no changes are needed and we get compatible types between dcalc and lcalc, allowing to deduplicate a few functions.
It might not be the best in the long run: there are still benefits in factorising small parts of the AST as suggested in #157 , and this forces a central AST definition that makes the nanopass-like approach a bit less legible.
Still, I think it's a step in the right direction and it doesn't really lock us in keeping to use the big GADT (as the minimal cascade of changes show).
2022-08-12 16:55:30 +02:00
Denis Merigoux
62b984c83c
Don't print functions in interpreter
2022-08-11 18:13:25 +02:00
Raphaël Monat
3e71f25bfe
Post merge fixes on using dates_calc
2022-08-06 17:49:06 +02:00
Raphaël Monat
ffd2e1dec3
Merge branch 'master' into dates_calc_lib
2022-08-06 17:26:55 +02:00
Raphaël Monat
4f12338d49
Switch from calendarlib to in-house dates_calc
2022-08-06 17:07:01 +02:00
Denis Merigoux
4d465b33b4
Helpful error message when trying to interpret a scope with arguments
2022-08-06 13:35:17 +02:00
Emile Rolley
ba620fca28
ocamlformat: new break-infix rule
2022-08-05 10:55:48 +02:00
Emile Rolley
d85812109c
refactor(compiler): remove the camomile dependency due to the new Utils.String_common module based on Ubase
2022-08-05 10:55:45 +02:00
Denis Merigoux
fa55a83fb4
Merge branch 'master' into 290-jsoo-wrapper-plugin
2022-07-22 17:54:51 +02:00
Emile Rolley
0c180e12f9
refactor(runtimes): add runtime_ocaml and runtime_jsoo in the catala package
2022-07-22 16:52:56 +02:00
Denis Merigoux
dc00ce8957
Merge branch 'master' into aides_logement
2022-07-22 16:49:01 +02:00
Denis Merigoux
522deb50c2
Factorizing Dcalc.program
2022-07-22 15:49:57 +02:00
Denis Merigoux
0304602433
Trying to fix Bindlib unboxing bug [skip ci]
2022-07-22 12:31:05 +02:00
Denis Merigoux
dcf80f4bec
Adding first_day_of_month and last_day_of_month
2022-07-21 14:14:04 +02:00
Denis Merigoux
58cb48fb28
Merge remote-tracking branch 'origin/master' into aides_logement
2022-07-20 11:20:00 +02:00
Louis Gesbert
e2e90cd080
Remove stale comment in dune file
2022-07-20 10:57:56 +02:00
Louis Gesbert
d9fbaa704b
Restore some commented out code, add some comments
2022-07-19 21:41:55 +02:00
Louis Gesbert
b9099ac7a4
Use resolved types in type annotations
...
Adding an 'inferring' annotation type only used during typing
2022-07-19 18:47:00 +02:00
Denis Merigoux
be373f0ff5
Added primitives money_to_decimal and decimal_to_money [skip ci]
2022-07-19 11:53:09 +02:00
Denis Merigoux
fffa318144
Don't print functions on CLI tracing mode; they're too big
2022-07-13 17:27:08 +02:00
Louis Gesbert
61063b5234
Small cleanup and clarifying a dark spot of the Ast interface
2022-07-13 12:28:08 +02:00
Louis Gesbert
83de1a229b
Mark the optimization passes as untyped
...
It's not expected to stay that way forever, but some additional effort will be required for them to preserve (or restore) types; until then, be safe and don't forward possibly incorrect information.
2022-07-13 12:17:43 +02:00
Louis Gesbert
7485c7f2ce
Reformat
2022-07-11 17:42:34 +02:00
Louis Gesbert
504f54c31e
Rework type error reporting
2022-07-11 17:42:34 +02:00
Louis Gesbert
02fc255177
Typing scopes: bottom-up rather than top-down
...
it's better for error messages (and similar to how it was done before)
2022-07-11 17:42:34 +02:00
Louis Gesbert
18e86621d5
Port verification code to the AST changes
2022-07-11 17:42:34 +02:00
Louis Gesbert
5f882e35a2
dcalc ast: make the map function more polymorphic
2022-07-11 17:42:34 +02:00
Louis Gesbert
49efb5ddd7
Improve debugging, add backtraces (when recording is enabled)
2022-07-11 17:42:34 +02:00
Louis Gesbert
296a1de7dd
Typing: add functions to type scopes without conversion to expr
2022-07-11 17:42:34 +02:00
Louis Gesbert
4eb5933ad0
Porting the interpreter to the marked AST
2022-07-11 17:42:30 +02:00
Louis Gesbert
6cc2e9a07b
typing.ml: fix use of bindlib
2022-07-11 16:51:54 +02:00
Louis Gesbert
67179a793c
Add type annotations on all AST nodes (first pass)
2022-07-11 16:51:54 +02:00
Louis Gesbert
513647cd32
AST simplification: remove redundant annotations
...
The AST structures track annotations (e.g., at the moment, source code
position information) in a lot of places. This patch tidies up a bit and
removes some duplication, ensuring a single level of annotation wrapping
at each AST recursion level.
This will be important when adding type information in these
annotations, because there will be consitency constraints to be ensured
and duplication is a likely source of mistakes.
2022-07-11 16:51:54 +02:00
Louis Gesbert
af0ac95682
Propagate renaming of Pos.mark*
into module Marked
...
this patch is just a bunch of `sed` commands
```shell
cd compiler
sed -i 's/Pos.marked/Marked.pos/g' *.ml* **/*.ml*
sed -i 's/Pos.unmark/Marked.unmark/g' *.ml* **/*.ml*
sed -i 's/Pos\.get_position/Marked.get_mark/g' *.ml* **/*.ml*
sed -i 's/Pos\.same_pos_as/Marked.same_mark_as/g' *.ml* **/*.ml*
sed -i 's/Pos\.map_under_mark/Marked.map_under_mark/g' *.ml* **/*.ml*
sed -i 's/Pos\.mark/Marked.mark/g' *.ml* **/*.ml*
sed -i 's/Pos\.compare_marked/Marked.compare/g' *.ml* **/*.ml*
```
2022-07-11 16:51:54 +02:00
kescher
db9eec3b9f
add support for duration multiplication
...
Signed-off-by: Jonathan Protzenko <protz@microsoft.com>
2022-05-31 11:17:38 -07:00
Louis Gesbert
f9fc1a8e8b
Formatting: sync with master
2022-05-12 15:10:55 +02:00
Denis Merigoux
025382a85d
Restore debug info
2022-05-05 14:34:29 +02:00
Denis Merigoux
c7b84ca2d0
Merge pull request #244 from CatalaLang/c_backend
...
Bringing structure to the Lcalc AST
2022-05-05 14:22:26 +02:00
Denis Merigoux
78e8275d5e
Adds a decimal rounding operator
2022-04-29 21:18:15 +02:00
Denis Merigoux
6ea73a4291
Progress on refactoring [skip ci]
2022-04-26 12:07:39 +02:00
Denis Merigoux
c1c2953131
Fixing more errors [skip ci]
2022-04-25 10:19:04 +02:00
Denis Merigoux
88a522d120
Changed maps and folds for Dcalc
2022-04-15 12:16:22 +02:00
Denis Merigoux
8be3d1cfc9
Made more functions generic in Dcalc.Ast
2022-04-12 17:54:00 +02:00
Denis Merigoux
e7440e043c
Remove duplicated function
2022-04-12 17:07:00 +02:00
Denis Merigoux
33ff03a356
Map visitor for Dcalc
2022-04-12 11:51:33 +02:00
Denis Merigoux
b24dbc8360
Remove logging calls for vc generation
2022-04-12 11:14:39 +02:00
Denis Merigoux
48dda14dcd
Merge branch 'master' into c_backend
2022-04-12 10:53:46 +02:00
Denis Merigoux
a43f89a0f4
Parametrize Dcalc.scope_expr
2022-04-12 10:53:07 +02:00
Denis Merigoux
6f223d2519
Restore web build
2022-04-11 10:59:40 +02:00
Romain PRIMET
eafab30809
fix typo
2022-04-07 22:43:05 +02:00
Denis Merigoux
f2d1fab263
Refactoring to clean some Dcalc passes
2022-04-06 09:48:34 +02:00
Denis Merigoux
f6047a43ea
Added boxed constructors for Dcalc
2022-04-06 09:35:07 +02:00
Denis Merigoux
f6c8e7fbd9
Crediting author of moved code
2022-04-04 18:06:40 +02:00
Denis Merigoux
9d05dad3fb
Passing all tests!
2022-04-04 15:56:45 +02:00
Denis Merigoux
84144c0a56
Tests now passing except for a few position and printing issues [skip ci]
2022-04-04 12:25:00 +02:00
Denis Merigoux
2652b9c406
Continuing to adapt code to new binded representation [skip ci]
2022-04-02 14:51:11 +02:00
Denis Merigoux
8f39b65bb6
Started replacement of Ast by Binded_representation in Dcalc [skip-ci]
2022-04-02 12:29:43 +02:00
Denis Merigoux
cdac6de9fe
Implement the round money builtin
2022-03-17 12:30:14 +01:00
Aymeric Fromherz
9eec6a474c
format
2022-03-08 20:43:55 +01:00
Aymeric Fromherz
9cbfc13288
Merge branch 'master' into afromher_dcalc
2022-03-08 20:41:35 +01:00
Aymeric Fromherz
3fb14264c2
Implement equal_ops in dcalc
2022-03-08 20:39:45 +01:00
Aymeric Fromherz
ac42bf65a7
Refactor to extract common equal_exprs_list and equal_typs_list
2022-03-08 20:31:22 +01:00
Aymeric Fromherz
5b345b4782
format
2022-03-08 20:23:45 +01:00
Aymeric Fromherz
2fa2f36c1d
Optimize if_then_else when both branches are identical
2022-03-08 17:38:14 +01:00
Aymeric Fromherz
89d69c2316
Implement equality function on dcalc expressions
2022-03-08 17:35:08 +01:00
Denis Merigoux
5bd66142a6
Big reformatting
...
ocamlformat 0.19.0 -> 0.20.1
100 -> 80 columns per line
Reestablished @emilerolley's smart fun break
2022-03-08 15:03:14 +01:00
Denis Merigoux
c07bab1377
FIXME -> TODO
2022-03-08 14:55:48 +01:00
Louis Gesbert
12ec65601d
Use format strings directly in debug/error/log functions
...
This avoids many intermediate calls to e.g. `Format.asprintf`; should result in
some cases in "more correct" use of `Format`¹, avoid the computation of unused
debug strings, and make the code more readable.
¹ for `Format` to work as expected, all intermediate calls need to go through
it. Some cases of formatting to an intermediate string then printing through Format
again are still present, but this makes the situation better.
2022-03-08 13:04:27 +01:00
Denis Merigoux
c65c38a2d5
Correct flag for enabling optimization
2022-02-24 16:46:02 +01:00
Alain
6fe75f3486
fv --> free_vars_set
...
free_vars --> free_vars_list
2022-02-21 11:51:01 +01:00
Alain
d7b9aa9492
fixing if-then-else bug
2022-02-18 16:11:22 +01:00
Alain
d512b27e2c
fmt
2022-02-18 15:49:23 +01:00
Alain
19bf2d934f
dcalc review
2022-02-18 15:31:52 +01:00
Denis Merigoux
48f064ccea
Adapt translation to new i/o invariants, bug discovered
2022-02-15 11:38:56 +01:00
Denis Merigoux
cab4e5c17e
Merge branch 'master' into alain_default-option
2022-02-15 10:20:53 +01:00
Denis Merigoux
b25f64c3ae
Improve printing
2022-02-14 17:01:34 +01:00
Denis Merigoux
69a7465339
Merge branch 'master' into alain_default-option
2022-02-14 12:09:11 +01:00
Denis Merigoux
9a718c6ced
Format comments
2022-02-14 12:07:35 +01:00
Alain
80fa3110eb
documentation + finished translating cut to hoist + copyright inside the compile_without_exceptions
2022-02-12 08:08:13 +01:00
Alain
77051cadba
fmt
2022-02-11 11:40:24 +01:00
Alain
cf28a58342
cut --> hoist
...
binded representation
few doc
2022-02-11 11:38:18 +01:00
Denis Merigoux
9bb858b79b
Added input/output/internal description in tutorial
2022-02-09 18:06:03 +01:00
Denis Merigoux
cb04ef3f9d
OnlyInput variables nore more thunked
2022-02-09 15:34:13 +01:00
Denis Merigoux
f3928dee9d
Better printing [skip ci]
2022-02-09 15:06:21 +01:00
Denis Merigoux
30061b8c86
Better encoding of inputs [skip ci]
2022-02-09 11:37:52 +01:00
Denis Merigoux
72274057cd
Better Dcalc printing
2022-02-06 18:25:37 +01:00
Denis Merigoux
97f8875a39
Merge branch 'master' into alain_default-option
2022-02-04 15:35:52 +01:00
Denis Merigoux
a06dfbfaa5
Assets and formatting
2022-02-04 15:29:31 +01:00
Denis Merigoux
11d4a34783
Better printing, tests, fix parser ommission
2022-02-04 15:10:47 +01:00
Alain
02187b4bc7
removed useless file
2022-02-04 14:53:47 +01:00
Alain
6da5cc518b
cleanup dcalc-ast.ml
2022-02-04 12:33:26 +01:00
Alain
88eedbc000
ocamlformat
2022-02-04 09:27:10 +01:00
Alain
b777d3215b
computing of free vars+ more debuging
...
finally found an error (List.fold_left instead of List.fold_right
2022-02-04 09:24:51 +01:00
Denis Merigoux
0d90dcea00
Better optimizations with values instead of literals
2022-02-02 10:30:39 +01:00
Denis Merigoux
effc2b24e4
Optimizations for defaults in Dcalc
2022-01-31 15:27:58 +01:00
Denis Merigoux
73ce2f142f
Fixed last bug around rule refactoring
2022-01-31 13:55:25 +01:00
Denis Merigoux
13b476d0a1
[skip ci] reorganized desugared to scope encoding, broke some invariants
...
WIP: fixed some bugs and provided documentations but one thing missing
2022-01-28 17:31:31 +01:00
Alain
1bfb891aa1
printing dcalc and lcalc ast
2022-01-25 13:55:17 +01:00
Denis Merigoux
d2977b48ce
Documentation pass
2022-01-19 10:54:16 +01:00
Denis Merigoux
0831f462ae
Correct signature
2022-01-12 16:28:03 +01:00
Denis Merigoux
16d8554384
Provide a function that removes all log calls
2022-01-12 16:25:46 +01:00
Denis Merigoux
d705334d9e
Merge branch 'master' into proof_platform
2022-01-11 15:43:33 +01:00
Denis Merigoux
f8dc1494f0
Autoformatting
2022-01-10 18:36:14 +01:00
Alain
5c5bc77c87
formatting (sorry, problem with the makefile)
2022-01-10 17:53:48 +01:00
Alain
baa435d2c5
optimization for not
2022-01-10 17:28:37 +01:00
Louis Gesbert
8d059b420e
Fix console formatting with colors
...
closes #174
2022-01-10 15:56:55 +01:00
Denis Merigoux
ca7b009b02
Should compile
2022-01-10 14:35:51 +01:00
Denis Merigoux
ab194c76fd
Give function for retrieving variable types
2022-01-10 14:32:27 +01:00
Denis Merigoux
1fcd66ba78
Made pretty printing without logs for dcalc
2022-01-10 14:19:04 +01:00
Denis Merigoux
4082e5056e
More prettier things
2022-01-10 10:59:30 +01:00
Denis Merigoux
3a864b6160
Aesthetic improvements
2022-01-10 10:28:14 +01:00
Denis Merigoux
ad4218285d
Working partial evaluation for Dcalc using ugly but correct style
2022-01-09 19:16:34 +01:00
Denis Merigoux
743a1b74c9
Renamed and grouped modules cleanly
2022-01-08 18:37:04 +01:00
Aymeric Fromherz
8b6595426e
Add Lt node and int literals
2022-01-07 18:54:15 +01:00
Aymeric Fromherz
ce80d1e9e9
Omit Log node from VC generation
2022-01-07 18:47:53 +01:00
Denis Merigoux
71a2f85d7c
Comments
2022-01-07 18:44:10 +01:00
Denis Merigoux
546107bfb0
Merge branch 'proof_platform' of github.com:CatalaLang/catala into proof_platform
2022-01-07 18:37:30 +01:00
Denis Merigoux
50224851f5
Port optimizations to Dcalc
2022-01-07 18:36:56 +01:00
Aymeric Fromherz
cc8e88ec4e
Start supporting unary operators
2022-01-07 18:36:25 +01:00
Aymeric Fromherz
75b42423c6
Start encoding literals to Z3
2022-01-07 18:25:35 +01:00
Aymeric Fromherz
98b5518638
Add support for Z3 encoding of if_then_else
2022-01-07 18:23:46 +01:00
Aymeric Fromherz
f2bd803f0f
Add support for Z3 encoding of binary operators application
2022-01-07 18:14:01 +01:00
Aymeric Fromherz
1105858bea
Setting up the pipeline for encoding VCs to Z3
2022-01-07 17:50:45 +01:00