Commit Graph

441 Commits

Author SHA1 Message Date
adelaett
920bd29835
documentation and deadcode elim 2023-04-14 13:59:06 +02:00
adelaett
f21cb1ff69
adding comment 2023-04-14 12:18:28 +02:00
adelaett
6b6272b0f2
adding an nicer error message 2023-04-14 12:16:09 +02:00
adelaett
123ae9e4c1
rename functions to make the code more readable 2023-04-14 12:15:16 +02:00
adelaett
0c357d2972
adding typing information for monad_* functions 2023-04-14 12:13:33 +02:00
adelaett
167ec9189f
adding a todo related to handle_default and handle_default_opt for
the closure conversion.
2023-04-14 12:02:03 +02:00
adelaett
5833608179
deadcode elim 2023-04-14 10:56:15 +02:00
adelaett
a53bc27d23
documentation 2023-04-14 10:48:31 +02:00
adelaett
cc66023e51
Thunking justifications and conclusion in avoid_translation pass 2023-04-12 10:58:21 +02:00
adelaett
49e9846386
fix a bug in the translation 2023-04-11 16:14:25 +02:00
adelaett
0cfc446455
implementing the behavior of handle_exceptions_opt for the lcalc interpretor 2023-04-11 14:09:57 +02:00
adelaett
3e35d4b826
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-11 11:49:22 +02:00
adelaett
0e8eed7ee1 program equality function 2023-04-07 12:10:08 +02:00
adelaett
6c7ac061d4 fix identation and use new formatting functions as default 2023-04-07 11:57:14 +02:00
adelaett
12d85570e8 fix printing boxes & merge issues 2023-04-07 10:51:21 +02:00
adelaett
9b63743c2f documentation 2023-04-07 10:49:48 +02:00
alain
ec40de83fc
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-06 13:57:22 +02:00
adelaett
7ebfb2e66a typo 2023-04-06 13:42:40 +02:00
Louis Gesbert
0098f00512 Yet some more small improvements to the AST encoding 2023-04-05 10:32:58 +02:00
adelaett
82992e9858 documentation 2023-04-04 17:02:26 +02:00
adelaett
60f8c229d5 fix to_ocaml new handledefault and handledefault opt operator 2023-04-04 15:57:33 +02:00
adelaett
06f2e56c74 fix closure conversion non-existent variable 2023-04-04 15:57:11 +02:00
adelaett
8ef3db005f clean deadcode 2023-04-04 15:56:49 +02:00
adelaett
b6cf552913 lcalc optimization documentation 2023-04-04 15:17:59 +02:00
adelaett
685785eaa3 adding assert_closed function 2023-04-03 11:20:19 +02:00
adelaett
e9ead93f3f fix typing errors 2023-03-31 16:01:05 +02:00
adelaett
573df8416f Merge branch 'master' into adelaett-withoutexceptionsfix 2023-03-31 15:52:06 +02:00
adelaett
272dc9e8b3 optimization reorg 2023-03-31 15:37:18 +02:00
adelaett
beeecce091 correcting filter definition 2023-03-31 15:31:43 +02:00
adelaett
69ac8ca929 implementation of fold, reduce, map & filter in without exceptions
Work in progress: not working for filter & map
2023-03-31 11:24:43 +02:00
Louis Gesbert
038861a52c Generic mapping function across different ASTs
Used in lcalc/compile_with_exceptions only at the moment
2023-03-30 18:57:51 +02:00
Louis Gesbert
1208744c6b EmptyError is no longer a literal
it's much simpler to handle it as an AST node, as that makes the literal
identical across all AST passes.
2023-03-30 18:54:50 +02:00
Louis Gesbert
4973c74410 Remove date rounding mode from Operator.translate 2023-03-30 15:33:00 +02:00
adelaett
61830bc348 fixing runtime merge errors 2023-03-30 11:02:35 +02:00
adelaett
6dee3874cc Merge branch 'master' into adelaett-withoutexceptionsfix 2023-03-30 10:50:32 +02:00
adelaett
7174480153 start of the translation of fold 2023-03-30 10:39:23 +02:00
adelaett
3e8aae99fe typo in the traslation of lets 2023-03-30 10:39:07 +02:00
adelaett
729d634744 fixing translation of arrays 2023-03-30 10:38:54 +02:00
adelaett
df740eed05 fixing with-exceptions 2023-03-28 10:07:01 +02:00
adelaett
f3abc23c32 fixings tests (90% atm) 2023-03-28 09:54:44 +02:00
adelaett
c3d9ee299f without exception: removing thunking 2023-03-28 09:54:04 +02:00
adelaett
9806eb7e0f format for program 2023-03-23 13:46:17 +01:00
adelaett
72ceafd67c scopes does not return optional terms 2023-03-23 10:45:44 +01:00
adelaett
78c0842dc6 optimization tests 2023-03-21 14:31:45 +01:00
Denis Merigoux
aa8ab3be3d
Merge branch 'master' into c_backend 2023-03-21 12:14:10 +01:00
adelaett
d2da1c3e43 advancing 2023-03-17 17:24:51 +01:00
adelaett
7c39ad953b fix iota optmi 2023-03-17 17:23:10 +01:00
adelaett
61ad00f277 unit test infrastructure for optimization 2023-03-17 17:19:50 +01:00
adelaett
850a1fdb56 more optimization on fold 2023-03-17 11:34:52 +01:00
adelaett
82af9e8305 unfolding more bugs 2023-03-16 17:14:33 +01:00
Raphaël Monat
7021c41f93 Add date rounding option within scopes 2023-03-16 16:55:55 +01:00
adelaett
26551434f2 correct monadic bind & map implementation 2023-03-14 18:36:05 +01:00
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