Commit Graph

439 Commits

Author SHA1 Message Date
adelaett
366a0d952b introducing new operators for handleing defaults 2023-03-14 18:30:58 +01:00
adelaett
4d3b021eef finished the implementation, but a few issues are missing 2023-03-13 16:51:06 +01:00
adelaett
b891114b72 tentative at a fully monadic encoding 2023-03-10 15:35:03 +01:00
adelaett
6c0e04942f corrected iota optimization 2023-03-06 16:00:41 +01:00
adelaett
78f121b44a before any issues with mark on code_item 2023-03-03 11:39:55 +01:00
adelaett
73bd4b4064 finished to detect unpure subexpressions 2023-02-28 14:26:48 +01:00
adelaett
001a8205af ? 2023-02-28 08:39:30 +01:00
adelaett
6c3f0af9e0 invariant assertion checking 2023-02-27 11:20:59 +01:00
adelaett
9a68563488 assert_internal & skeleton for the static pass 2023-02-27 11:20:59 +01:00
adelaett
8784ae6175 unpure detection in expressions 2023-02-27 11:20:59 +01:00
adelaett
0262019d45 make app 2023-02-27 11:20:59 +01:00
adelaett
363ef39704 let case 2023-02-27 11:20:59 +01:00
adelaett
2a222f0aab changed nix dependency from ocamlformat 24.1 to 21.0 2023-02-27 11:20:59 +01:00
adelaett
e765ee8a0c requesting to have a typed tree 2023-02-27 11:20:59 +01:00
adelaett
44ce5a636b fix tentative for functions applications 2023-02-27 11:20:59 +01:00
adelaett
5b33b39636 new helpers functions in lcalc's ast 2023-02-27 11:20:59 +01:00
adelaett
839a7ffd83 finished refactoring 2023-02-20 17:58:29 +01:00
Louis Gesbert
72cf477dd9 Toplevel definitions: fixes following review
Thanks @denismerigoux!
2023-02-15 12:40:15 +01:00
Louis Gesbert
c3af0b4097 Toplevel definitions: branch cleanup
- fix remaining warnings (mostly unused arguments)
- renamings throughout for consistency and clarity
2023-02-13 18:02:09 +01:00
Louis Gesbert
9b0c7583ec Add top-level definitions
Only handled until before scalc at the moment.
2023-02-13 11:43:49 +01:00
Louis Gesbert
0540cd31fe Allow ETuple, ETupleAccess on all ASTs
they used to be only allowed on lcalc
2023-02-13 10:51:42 +01:00
Denis Merigoux
7702949401
Better printing 2023-02-08 16:03:23 +01:00
Denis Merigoux
c78a004b53
Leave everything unresolved for now 2023-02-08 16:00:53 +01:00
Denis Merigoux
7d6abf36b2
Taking into account that closures can be input and output of scopes 2023-02-08 16:00:21 +01:00
Denis Merigoux
3577507ee9
Switch from closure-passing to environment-passing closure conversion 2023-02-08 16:00:21 +01:00
Denis Merigoux
38d5ef9715
Small improvement 2023-02-08 15:59:51 +01:00
Denis Merigoux
4521d05839
Starting to implement hoisting 2023-02-08 15:59:51 +01:00
Denis Merigoux
83e9e83909
Progressing [skip ci]
Testing with dune exec catala -- Lcalc -s S tests/test_func/good/closure_conversion.catala_en  --avoid_exceptions -O --closure_conversion
2023-02-08 15:59:51 +01:00
Louis Gesbert
fea01cfe4c Add overloaded operators for the common operations
This uses the same disambiguation mechanism put in place for
structures, calling the typer on individual rules on the desugared AST
to propagate types, in order to resolve ambiguous operators like `+`
to their strongly typed counterparts (`+!`, `+.`, `+$`, `+@`, `+$`) in
the translation to scopelang.

The patch includes some normalisation of the definition of all the
operators, and classifies them based on their typing policy instead of
their arity. It also adds a little more flexibility:
- a couple new operators, like `-` on date and duration
- optional type annotation on some aggregation constructions

The `Shared_ast` lib is also lightly restructured, with the `Expr`
module split into `Type`, `Operator` and `Expr`.
2022-12-13 11:55:24 +01:00
Louis Gesbert
3f2aa19e97 Add ambiguous StructAccess for desugared
to be resolved in scopelang
2022-11-28 16:38:09 +01:00
Louis Gesbert
af2f5dbe19 Tweak error message location printing 2022-11-28 16:38:09 +01:00
Louis Gesbert
9fc4c0c10c Define Catala_utils.String as an overlay to stdlib string 2022-11-28 16:38:09 +01:00
Louis Gesbert
660e5775de Rename utils to catala_utils 2022-11-28 16:38:09 +01:00
Louis Gesbert
b329afbbdb Rename all Map/Set calls accordingly
This is just a bunch of `sed` calls:
```shell
sed -i 's/ScopeSet/ScopeName.Set/g' compiler/**/*.ml*
sed -i 's/ScopeMap/ScopeName.Map/g' compiler/**/*.ml*
sed -i 's/StructMap/StructName.Map/g' compiler/**/*.ml*
sed -i 's/StructSet/StructName.Set/g' compiler/**/*.ml*
sed -i 's/EnumMap/EnumName.Map/g' compiler/**/*.ml*
sed -i 's/EnumSet/EnumName.Set/g' compiler/**/*.ml*
sed -i 's/StructFieldName/StructField/g' compiler/**/*.ml*
sed -i 's/StructFieldMap/StructField.Map/g' compiler/**/*.ml*
sed -i 's/StructFieldSet/StructField.Set/g' compiler/**/*.ml*
sed -i 's/EnumConstructorMap/EnumConstructor.Map/g' compiler/**/*.ml*
sed -i 's/EnumConstructorSet/EnumConstructor.Set/g' compiler/**/*.ml*
sed -i 's/RuleMap/RuleName.Map/g' compiler/**/*.ml*
sed -i 's/RuleSet/RuleName.Set/g' compiler/**/*.ml*
sed -i 's/LabelMap/LabelName.Map/g' compiler/**/*.ml*
sed -i 's/LabelSet/LabelName.Set/g' compiler/**/*.ml*
sed -i 's/ScopeVarMap/ScopeVar.Map/g' compiler/**/*.ml*
sed -i 's/ScopeVarSet/ScopeVar.Set/g' compiler/**/*.ml*
sed -i 's/SubScopeNameMap/SubScopeName.Map/g' compiler/**/*.ml*
sed -i 's/SubScopeNameSet/SubScopeName.Set/g' compiler/**/*.ml*
```

... and reformat
2022-11-28 16:38:09 +01:00
Louis Gesbert
47799ea24f Uniform naming of conversion modules across compilation passes 2022-11-22 12:08:18 +01:00
Louis Gesbert
4ae392c900 AST refactoring
Many changes got bundled in here and would be too tedious to separate.

Closes #330

See changes in `shared_ast/definitions.ml` to check the main point.

- the biggest change is a modification of the struct and enum types in
  expressions: they are now stored as `Map`s throughout passes, and no longer
  converted to indexed lists after scopelang. Their accessors are also changed,
  and tuples only exist in Lcalc (they're used for closure conversion).

  This implied adding some more information in the contexts, to keep the mapping
  between struct fields and scope output variables. It should also be much more
  robust (no longer relying on assumptions upon different orderings).

- another very pervasive change is more cosmetic: the rewrite of the main AST to
  use inline records, labelling individual subfields.

- moved the checks for correct definitions and accesses of structures from
  `Scope_to_dcalc` to `Typing`

- defining some new shallow iterators in module `Shared_ast.Expr`, and
  factorising a few same-pass rewriting functions accordingly (closure
  conversion, optimisations, etc.)

- some smaller style improvements (ensuring we use the proper compare/equal
  functions instead of `=` in a few `when` closes, for example)
2022-11-17 18:16:09 +01:00
Louis Gesbert
7267543ca1 Rename Expr.Box.inj to Expr.Box.lift
it is more consistent with the naming of functions in Bindlib.
2022-10-21 15:35:49 +02:00
Louis Gesbert
e925ec1795 Swap boxing and annotations in expressions
This was the only reasonable solution I found to the issue raised
[here](https://github.com/CatalaLang/catala/pull/334#discussion_r987175884).

This was a pretty tedious rewrite, but it should now ensure we are doing things
correctly. As a bonus, the "smart" expression constructors are now used
everywhere to build expressions (so another refactoring like this one should be
much easier) and this makes the code overall feel more
straightforward (`Bindlib.box_apply` or `let+` no longer need to be visible!)

---

Basically, we were using values of type `gexpr box = naked_gexpr marked box`
throughout when (re-)building expressions. This was done 99% of the time by
using `Bindlib.box_apply add_mark naked_e` right after building `naked_e`. In
lots of places, we needed to recover the annotation of this expression later on,
typically to build its parent term (to inherit the position, or build the type).

Since it wasn't always possible to wrap these uses within `box_apply` (esp. as
bindlib boxes aren't a monad), here and there we had to call `Bindlib.unbox`,
just to recover the position or type. This had the very unpleasant effect of
forcing the resolution of the whole box (including applying any stored closures)
to reach the top-level annotation which isn't even dependant on specific
variable bindings. Then, generally, throwing away the result.

Therefore, the change proposed here transforms
- `naked_gexpr marked Bindlib.box` into
- `naked_gexpr Bindlib.box marked` (aliased to `boxed_gexpr` or `gexpr boxed` for
convenience)

This means only
1. not fitting the mark into the box right away when building, and
2. accessing the top-level mark directly without unboxing

The functions for building terms from module `Shared_ast.Expr` could be changed
easily. But then they needed to be consistently used throughout, without
manually building terms through `Bindlib.apply_box` -- which covers most of the
changes in this patch.

`Expr.Box.inj` is provided to swap back to a box, before binding for example.

Additionally, this gives a 40% speedup on `make -C examples pass_all_tests`,
which hints at the amount of unnecessary work we were doing --'
2022-10-07 18:00:23 +02:00
Louis Gesbert
14f1ebfd0a Reformat 2022-10-04 14:50:37 +02:00
Louis Gesbert
ea114bada2 Fix one more typing mismatch 2022-10-04 14:50:37 +02:00
Louis Gesbert
0bb9cce341 Simplify a few mark operations 2022-10-04 14:50:37 +02:00
Louis Gesbert
d93b699a4c Forward types in the Expr.make_* constructors
Also add some safeguards against bad propagation of types (e.g. checking the
arrow type of functions upon application); partly disabled at the moment since
they don't pass yet but that'll be further work.
2022-10-04 14:50:37 +02:00
Denis Merigoux
6130151c8e
Fix bug and typos 2022-09-05 14:50:37 +02:00
Denis Merigoux
e5963e5381
Merge branch 'master' into altgr_allmarks 2022-08-29 11:57:06 +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
e10771c187
Make all supertypes use ('a, 't) gexpr as parameter instead of naked_gexpr 2022-08-29 10:57:21 +02:00
Louis Gesbert
a9c8bab2b3
Same treatment for typ and marked_typ 2022-08-29 10:57:21 +02:00
Louis Gesbert
0a23dc526d
Rename marked_expr -> expr, expr -> naked_expr throughout
Since the marked kind is used throughout, this should be more clear
2022-08-29 10:57:21 +02:00
Louis Gesbert
493b6703a7
Rename marked_gexpr -> gexpr, gexpr -> naked_gexpr
Since the marked kind is used throughout, this should be more clear
2022-08-29 10:57:21 +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
7ee971c4e1
Remove unused type definitions 2022-08-16 14:33:37 +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
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
Louis Gesbert
a569589193 Small improvements to the Python and OCaml pretty-printers 2022-08-04 20:43:39 +02:00
Denis Merigoux
4845196b5b Add source positions in all backends exceptions 2022-07-29 18:42:14 +02:00
Denis Merigoux
8d3e283669 Fix some bugs of JSOO plugin 2022-07-28 15:02:43 +02:00
Denis Merigoux
d17ac0bc39
More nitpicks 2022-07-22 18:04:16 +02:00
Denis Merigoux
fa55a83fb4
Merge branch 'master' into 290-jsoo-wrapper-plugin 2022-07-22 17:54:51 +02:00
Emile Rolley
ad0efd3447 refactor(ocaml): wrap enum type inside their own module like struct ones 2022-07-22 16:52:56 +02:00
Emile Rolley
0a9e563450 refactor(to_ocaml): format_to_struct_type -> format_to_module_name 2022-07-22 16:52:56 +02:00
Emile Rolley
3dcf856ec6 refactor(cli): add Cli.call_unstyled 2022-07-22 16:52:56 +02:00
Emile Rolley
b2bba6eaf0 feat(jsoo): factorize log events related function to the object eventManager 2022-07-22 16:52:56 +02:00
Emile Rolley
37a8cf7090 fix(rebase): changes Lcalc and Dcalc AST manipulation according #272 2022-07-22 16:52:56 +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
Emile Rolley
59f50f95e8 refactor(plugins/jsoo): use To_ocaml function directly by extending its interface 2022-07-22 16:52:56 +02:00
Emile Rolley
cda3bfb3aa feat(plugins/jsoo): format type declaration 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
b7c468bd1e
Fix faulty unboxing 2022-07-22 16:18:55 +02:00
Denis Merigoux
522deb50c2
Factorizing Dcalc.program 2022-07-22 15:49:57 +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
Denis Merigoux
6d224e1a41
Merge pull request #272 from AltGr/types-everywhere
Annotate the ASTs with type information everywhere
2022-07-20 11:07:17 +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
05115c7541
Help OCaml's type inference
Needed because of constructor name confusion
2022-07-14 15:29:50 +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
Emile Rolley
4991350b58 feat(backend/ocaml): disambiguate OCaml record names derived from Catala struct 2022-07-12 16:12:18 +02:00
Louis Gesbert
7485c7f2ce Reformat 2022-07-11 17:42:34 +02:00
Louis Gesbert
985ecdac6d Bump required OCaml version to 4.13
This version of OCaml introduces [let-punning](https://v2.ocaml.org/manual/bindingops.html#ss:letops-punning)

It is just syntactic sugar, but OCamlformat makes use of it, without a configuration option, when the OCaml version permits.
This means that the same version of OCamlformat gives different results depending on the underlying OCaml version. Our options, if we want to keep the forced-format policy on the repository, are therefore:
- to disable it whenever binding operators are used (with this PR that's a lot of places, and this becomes too cumbersome, besides defeating the purpose)
- to force devs to use an earlier version of OCaml so that reformatting outputs something compatible
- to bump the minimum OCaml requirement

The latter is the simplest, but it can be reviewed if compatibility is required. Last option would be to report the issue to OCamlformat and hope that they provide a workaround...
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
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
Emile Rolley
d82ecb5f12 fix(compiler/log): retrieve types of input and output function calls 2022-06-15 14:34:15 +02:00
Louis Gesbert
f17875f90e Formatting: some other personal preferences 2022-05-11 16:25:49 +02:00
Louis Gesbert
74c5629153 Formatting: reduce extra match-case indentation
2 is plenty enough, esp. for nested matches :)
2022-05-11 16:25:20 +02:00
Louis Gesbert
fa3693d813 Formatting: disable deprecated "smart" fun-decl option 2022-05-11 16:22:56 +02:00
Louis Gesbert
6cb0d581a6 Workaround some ocamlformat crashes
These files were not reformatted!
2022-05-11 16:21:07 +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
764edb6ef0
Refactoring finished 2022-04-26 16:06:36 +02:00
Denis Merigoux
6ea73a4291
Progress on refactoring [skip ci] 2022-04-26 12:07:39 +02:00
Denis Merigoux
40480fc4b0
Fix compile_with_exceptions [skip ci] 2022-04-25 18:00:08 +02:00
Denis Merigoux
c1c2953131
Fixing more errors [skip ci] 2022-04-25 10:19:04 +02:00
Denis Merigoux
8ce81fedaa
Start to refactor Lcalc AST (WIP) [skip ci] 2022-04-15 12:16:44 +02:00
Denis Merigoux
8be3d1cfc9
Made more functions generic in Dcalc.Ast 2022-04-12 17:54:00 +02:00
Denis Merigoux
33ff03a356
Map visitor for Dcalc 2022-04-12 11:51:33 +02:00
Denis Merigoux
a43f89a0f4
Parametrize Dcalc.scope_expr 2022-04-12 10:53:07 +02:00
Denis Merigoux
cbd975d53a
Remove unused stub 2022-04-04 18:07:47 +02:00
Denis Merigoux
e68fe42856
Put closure conversion prototype under a flag 2022-04-04 17:43:30 +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
be26fa2474
Implement app but lots of rtefactoring to do [skip ci] 2022-03-31 14:21:13 +02:00
Denis Merigoux
c7c774a1a1
Closure conversion: case of EAbs implemented 2022-03-31 12:19:31 +02:00
Denis Merigoux
be191de566
Some closures closed but buggy overall [skip ci] 2022-03-23 17:50:53 +01:00
Denis Merigoux
a660987df0
Starting to implement closure conversion [skip ci] 2022-03-21 17:26:23 +01:00
Denis Merigoux
25977de151
Prettify Scalc 2022-03-21 14:58:54 +01:00
Denis Merigoux
cdac6de9fe
Implement the round money builtin 2022-03-17 12:30:14 +01:00
Aymeric Fromherz
d760d883a6 [Z3encoding] Print variable name when encoding is not supported 2022-03-15 18:09:33 +01:00
Emile Rolley
709d4e5ae5 fix(lcalc): disable ocamlformat for let+ expressions 2022-03-08 16:13:47 +01:00
Emile Rolley
7c1f4cc02d refactor: group common functions related to backend_option in the Cli module 2022-03-08 15:52:26 +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
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
09dd02c8a0
Python backend works with exceptions avoided
Few bugs in Lcalc->Scalc fixed
2022-02-25 12:30:34 +01:00
Denis Merigoux
ddacc94de2
Correct types for make_some and make_none 2022-02-24 16:50:01 +01:00
Alain
4ee9b71e00 to_lcalc option type printing 2022-02-21 11:58:26 +01:00
Alain
f7b70b8f19 add typing information to make_none and make_some 2022-02-21 11:55:39 +01:00
Alain
5c9996e427 more comment 2022-02-18 15:59:35 +01:00
Alain
f54b3b317c review lcalc 2022-02-18 15:55:37 +01:00
Alain
d512b27e2c fmt 2022-02-18 15:49:23 +01:00
Alain
7e1057c541 review of lcalc 2022-02-18 15:47:54 +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
21c73edfc9
Link to modules in the docs 2022-02-14 18:27:29 +01:00
Denis Merigoux
1cec4b0721
Pretty-printer for scalc 2022-02-14 18:22:26 +01:00
Denis Merigoux
b25f64c3ae
Improve printing 2022-02-14 17:01:34 +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
Alain
8834034094
disable beta-reduction 2022-02-11 09:39:01 +01:00
Alain
72da935392 chaging pretty printer for type to Dcalc.Print.format_typ 2022-02-09 11:50:04 +01:00
Alain
bd0fe18cc3 handling with special care SubScopeVarDefinition using the invariant that is it thunked 2022-02-09 11:44:00 +01:00
Alain
29b734be46 reorganisation of the file compile_without exceptions
working binding of whole program

working translation
2022-02-09 11:30:35 +01:00
Alain
3a1ab17796 fix uncorrect scope definition
select only part of type transformation to do
2022-02-07 11:00:36 +01:00
Alain
ed2c192470 Add monomorphisation of eoptions types
Compilation as TAny is not enough clear to define structures in ocaml.
2022-02-07 10:58:41 +01:00
Alain
16e09a1e36 type translation 2022-02-07 09:17:23 +01:00
Alain
730bd71cd3 new invariant about assert in dcalc
it is now a pure function, and is always in the form EAssert (ErrorOnEmpty _).
2022-02-04 16:58:58 +01:00
Alain
c97ab86c1c removed un-used code 2022-02-04 16:50:40 +01:00
Alain
424b68a6a5 formatting 2022-02-04 16:43:59 +01:00
Alain
b44e8e4f08 changed optimization so it actually work 2022-02-04 16:25:57 +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
Alain
6ad948ed76 more cleanup in lcalc-ast 2022-02-04 15:13:28 +01:00
Alain
d9fbe4b499 use external pp in compile_without_exceptions
better error messages

fixed make_matchopt_with_abs_arms

fixed license

few documentation
2022-02-04 14:32:12 +01:00
Alain
541d5656ac print uid too in Lcalc.Print 2022-02-04 14:31:06 +01:00
Alain
08651d33af better error message in to_ocaml conversion 2022-02-04 14:30:42 +01:00
Alain
6da5cc518b cleanup dcalc-ast.ml 2022-02-04 12:33:26 +01:00
Alain
f8343d1d0c cleanup lcalc-ast.ml 2022-02-04 12:28:03 +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
Alain
9e301331e6 more printing 2022-02-03 18:56:37 +01:00
Alain
005646d2b2 implementation of scoping let function 2022-02-03 18:48:17 +01:00
Alain
ebc2adc53e removed comments 2022-02-03 18:30:58 +01:00
Alain
156dd71375 intermediate step 2022-02-03 18:27:55 +01:00
Alain
3e96db43ce more printing to debug 2022-02-03 17:16:45 +01:00
Alain
85fc1be4fb printing ctx at each steps but no error found so far. 2022-02-03 11:50:18 +01:00
Alain
4290059ab8 newline 2022-02-02 18:10:27 +01:00
Alain
6158a2e150 nicer error messages when Not_Found error is raised inside the compilation without exceptions.
added explicit match when finding [v ()] where v is a variable.

Correct position of ErrorOnEmpty.

added argument on translate_expr when adding an esome is not required

renamed "unit" to "_" (silent_var) for consistency
2022-02-02 17:33:36 +01:00
Alain
1db649db3e nicer internal error when Not_Found is raised inside the code generation of ocaml code. 2022-02-02 17:24:32 +01:00
Alain
d7c422d33c clarify make_matchopt + lcalc's ast ocamlformat 2022-02-02 12:23:52 +01:00
Alain
67ccfb0122 renamed the new file 2022-02-02 12:14:07 +01:00
Alain
2c4f9bfc7a removed the old file 2022-02-02 12:13:47 +01:00
Alain
3c5bc4f67e before removing the old file 2022-02-02 12:12:15 +01:00
Alain
717915bc86 more documentation 2022-02-02 12:10:47 +01:00
Alain
0a612bfe7d translate_scope_let 2022-02-02 12:01:05 +01:00
Alain
90a63ebead finished implementation of translation_expr + some documentation 2022-02-01 17:49:00 +01:00
Denis Merigoux
6cf1b768d2
Fix bug in Python backend producing unreachable code 2022-02-01 15:41:53 +01:00
Alain
fcf6fecf71 implementation of a few cases in the translation without exceptions 2022-01-28 11:07:29 +01:00
Alain
33d9d03dea advancing 2022-01-28 09:28:02 +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
777f194178
.mlis and ocamldoc [skip-ci] 2022-01-18 15:13:16 +01:00
Denis Merigoux
f8dc1494f0
Autoformatting 2022-01-10 18:36:14 +01:00
Louis Gesbert
8d059b420e Fix console formatting with colors
closes #174
2022-01-10 15:56:55 +01:00
Emile Rolley
397b0e1d7c fix(build/doc): remove warnings due to .ml* files 2022-01-02 14:53:51 +01:00
Alain
2d267471da tentative beta reduction 2021-12-17 15:32:20 +01:00
Alain
84cd6ddc61 error on empty everywhere 2021-12-17 15:27:34 +01:00
Alain
c3268cc13c more mistakes removed 2021-12-16 19:48:14 +01:00
Alain
63ff6cfbb3 wip (compiling but can't compile catala program without internal errors)
instrumentation of Dcalc.expr to show internals representation
2021-12-16 19:16:57 +01:00
Alain
3a09b39bf5 wip 2021-12-16 16:59:25 +01:00
Alain
0d1363b2f6 wip 2021-12-15 15:43:11 +01:00
Alain
65ad229373 scope_let translation 2/6 2021-12-15 09:23:03 +01:00
Alain
16b0dba9d0 Merge branch 'master' into feat/default-option 2021-12-14 10:27:11 +01:00
Denis Merigoux
00a998462a
Implementation OK, now on to debugging Bindlib [skip ci] 2021-12-10 16:30:36 +01:00
Denis Merigoux
50400c445d
Few progress 2021-12-09 23:29:49 +01:00
Denis Merigoux
c456a62cb3
Builds but with empty stubs [skip ci] 2021-12-09 22:59:39 +01:00
Alain
9c76b34afc removed assert false 2021-12-08 12:58:21 +01:00
Alain
df545e5761 add translate_binder
refactor make_bindopt
refactor make_matchopt
added make_bindmopt
remove _{i}_ printing in to_ocaml
add correct printing of handle_default_opt
add two-step translation
correct context for new variables
2021-12-07 18:57:28 +01:00
Alain
177a2149ac handle_opt 2021-12-07 16:03:15 +01:00
Alain
959203e595 add: error message when unary operator log is left somewhere it shouldn't 2021-12-01 15:48:58 +01:00
Alain
ac7df6cdd7 add: implementation of generic operator without the need of rewriting each one
add: error when using an operator not in the right place when using --avoid_empty
2021-12-01 15:48:18 +01:00
Alain
0dfac8210e fix invariant correction within ErrorOnEmpty 2021-12-01 15:43:19 +01:00
Alain
86fa2ea7fa correct bindlib utilization (cont) 2021-12-01 15:42:37 +01:00
Alain
3f8bc482f3 add refine iota transformation in lcalc 2021-12-01 15:42:01 +01:00
Alain
5f86837428 correct use of bindlib in the translation 2021-12-01 11:17:16 +01:00
Alain
fd8ff75079 renamed transform -> visitor_map 2021-12-01 10:12:00 +01:00
Alain
76f5e6115c changing signature -- cont 2021-11-30 18:05:30 +01:00
Denis Merigoux
604fbbf2bf
Stub of changing signature 2021-11-30 16:52:33 +01:00
Denis Merigoux
536dde9834
Formatting + CI + etc 2021-11-30 16:27:47 +01:00
Alain
8d580f1db6 fix: removed ESome and ENone constructions. 2021-11-29 17:53:07 +01:00
Alain
22af2a9335 refactored transformation to remove matchopt construction 2021-11-29 17:40:30 +01:00
Alain
cf43e3d87c add generic identity optimization helper
peephole transform using generic transformation
add iota reduction as an optimization
2021-11-29 17:40:13 +01:00
Alain
c2db3a40c6 ref: use of built-in match instead of matchopt (wip) 2021-11-26 17:10:31 +01:00
Alain
3bc71e8c43 modification to take into account the prevous commit 2021-11-25 18:55:23 +01:00
Alain
fcdaa21d54 add utilities that replace to deal with options 2021-11-25 17:27:06 +01:00
Denis Merigoux
7d3e381d45
Improvements with Alain during weekly meeting 2021-11-24 15:51:49 +01:00
Denis Merigoux
fb281a0d99
Formatting 2021-11-24 15:22:29 +01:00
Alain
949df1cd33 the translation executes correctly, but the result is totally unreadable 2021-11-24 11:01:45 +01:00
Alain
08b38472e2 found a bug inside the match translation. 2021-11-22 15:55:21 +01:00
Alain
f75341c44f making options default compilation target 2021-11-22 15:55:21 +01:00
Alain
53b40121ad should be ok, without handling the types 2021-11-22 15:55:21 +01:00
Alain
0f5fde2c5a advancing 2021-11-22 15:55:21 +01:00
Alain
41a8961285 tentative, trying something else 2021-11-22 15:55:21 +01:00
Alain
a24a4ab6df starting to work on type inference 2021-11-22 15:55:21 +01:00
Alain
6fdd739f54 saving my work somewhere 2021-11-22 15:55:21 +01:00
EmileRolley
ac47d1ff1a refactor(compiler): minor factorization of formatting functions inside the To_ocaml module 2021-07-08 17:00:24 +02:00
EmileRolley
731513a003 refactor(compiler): factorize formatters inside prints modules 2021-07-08 16:36:53 +02:00
EmileRolley
6169d19b1e feat(compiler): add collection concatenation operator 2021-07-08 16:27:46 +02:00
Denis Merigoux
eb9c75f394
Making progress into translation 2021-06-23 17:47:34 +02:00
Denis Merigoux
1313183353
Defining a new intermediate representation 2021-06-22 16:01:57 +02:00
Denis Merigoux
fffd0ffb63
Working the way into the Python backend 2021-06-22 14:55:43 +02:00
Denis Merigoux
9ab32efcce
Added machinery for Python backend 2021-06-21 18:00:06 +02:00
Denis Merigoux
bbd50747d9
Big renaming and dir reorg 2021-06-21 11:39:06 +02:00