Commit Graph

870 Commits

Author SHA1 Message Date
Louis Gesbert
817dcb09fc Simplify variable translation functions 2023-03-30 15:41:03 +02:00
Louis Gesbert
4973c74410 Remove date rounding mode from Operator.translate 2023-03-30 15:33:00 +02:00
Louis Gesbert
a415355a39 Rework the AST Gadt to allow merging of different ASTs
The phantom polymorphic variant qualifying AST nodes is reversed:
- previously, we were explicitely restricting each AST node to the passes where it belonged using a closed type (e.g. `[< dcalc | lcalc]`)
- now, each node instead declares the "feature" it provides using an open type (e.g. `[> 'Exceptions ]`)
- then the AST for a specific pass limits the features it allows with a closed type

The result is that you can mix and match all features if you wish,
even if the result is not a valid AST for any given pass. More
interestingly, it's now easier to write a function that works on
different ASTs at once (it's the inferred default if you don't write a
type restriction).

The opportunity was also taken to simplify the encoding of the
operators, which don't need a second type parameter anymore.
2023-03-30 15:30:08 +02:00
Aymeric Fromherz
b85a199daa
Add support for let .. in constructions in Z3 backend (#434) 2023-03-29 06:41:40 +09:00
Denis Merigoux
44d8c32b9f
C backend for Catala : the closure conversion strikes back (#364) 2023-03-28 09:53:22 +02:00
Denis Merigoux
e4c4339856
Small fixes 2023-03-28 09:38:47 +02:00
Aymeric Fromherz
5f04e0efaf cleanup 2023-03-28 13:08:24 +09:00
Aymeric Fromherz
c711b0b1d7 cleanup 2023-03-28 13:00:07 +09:00
Aymeric Fromherz
082caae498 Add support for let_in in Z3 backend 2023-03-28 12:48:44 +09:00
Louis Gesbert
69be2f6ed8 Fix literate output of dates 2023-03-21 16:59:34 +01:00
Denis Merigoux
48ef5b8f21
Fix warning and update assets 2023-03-21 14:00:49 +01:00
Denis Merigoux
578091f196
Restore check 2023-03-21 13:49:16 +01:00
Denis Merigoux
aa8ab3be3d
Merge branch 'master' into c_backend 2023-03-21 12:14:10 +01:00
Louis Gesbert
db09eb0c42
Add date rounding option in scope (#397) 2023-03-17 10:14:36 +01:00
Raphaël Monat
d5cd5b206a Show conflicting date rounding mode declarations when they happen 2023-03-16 18:51:01 +01:00
Raphaël Monat
8981b21edb Add test for date rounding option conflict 2023-03-16 17:20:14 +01:00
Raphaël Monat
51ea9d8cff Format code 2023-03-16 17:20:14 +01:00
Raphaël Monat
d3c27799de Raise exception when more than one rounding mode option has been specified 2023-03-16 17:20:13 +01:00
Raphaël Monat
1e1e3b538e Simplify format 2023-03-16 17:20:13 +01:00
Raphaël Monat
b013f4257d Update parser error message 2023-03-16 17:20:13 +01:00
Raphaël Monat
887ec00d0e Add explicit match 2023-03-16 17:20:13 +01:00
Raphaël Monat
64fa32392f Update generated files 2023-03-16 17:20:09 +01:00
Raphaël Monat
5fc1e8e5d5 Fix operator printing 2023-03-16 16:55:55 +01:00
Raphaël Monat
7021c41f93 Add date rounding option within scopes 2023-03-16 16:55:55 +01:00
Louis Gesbert
abc5a00c2f Compile LaTeX code using minted without the Python venv
This is a hack, but not a dirty one: a new command `catala pygmentize` is added,
which is just a wrapper around `pygmentize` that calls it with the proper lexers
defined.

The point is that this needs no installation, just a stock `pygmentize`
installation and the `catala` binary.
2023-03-14 17:35:22 +01:00
Louis Gesbert
f1e44619e0 LaTeX literate output: handle pygments coloration from within Catala
This leverages the embedded lexer already used for HTML output, and uses the
LaTeX pygments backend to colorise code directly, without the need for `minted`.
2023-03-13 22:33:48 +01:00
Louis Gesbert
5282aec400 LaTeX output: start refactor 2023-03-13 14:44:34 +01:00
Louis Gesbert
508992de33 Embed the Pygments Catala lexer
This enables the HTML output to work without a custom Pygments installation (or
the proper venv activated)
2023-03-13 14:41:24 +01:00
Louis Gesbert
e1fe37ad09 Fix coloration in HTML output 2023-03-09 15:46:00 +01:00
Louis Gesbert
deb12d2c4a Bump version to 0.8.0
Changelog:
---

A lot has been going on, with more than 530 patches and 70 PRs merged since
0.7.0 last summer. In summary:

- Quite a lot of syntax improvements and changes. Checkout the latest
  [cheat-sheet](https://catalalang.github.io/catala/syntax.pdf) for an overview

- Allow local `let ... equals ... in ...` definitions

- Better error messages and positions throughout

- Added the ability to directly call a scope and retrieve its outputs, like a
  function

- Added disambiguation, allowing to access structure fields without specifying
  the structure type each time

- Added automated resolution of operators, allowing e.g. to write just `+` in
  place of all the type-specific operators `+.`, `+$`, `+@`, `+^`, etc.

- More consistent priority for operators. It is no longer allowed to write `a
  and b or c` without parenthesis.

- Added and changed some operators (`date + duration` now allowed either way,
  `int / int` now returns a decimal, added `duration / duration`)

- Added the ability to have variables and functions defined at
  top-level (outside of any scope). See annex A of the tutorial for details.

- Added support for functions with multiple arguments

- Some big refactors in the compiler, allowing much better code sharing between
  the different passes, and making it much easier to extend. Also added the
  possibility to run the type-checker earlier, etc.

- Countless bug-fixes

- Improvements to our proof backend with Z3

- A tool to automatically synchronise with the upstream French law from
  Legifrance
2023-03-08 18:07:53 +01:00
Louis Gesbert
6388a4b79f Improved some error messages (cyclic defs, def positions) 2023-03-08 15:27:48 +01:00
Louis Gesbert
188a186735 Parser: make state rule syntax consistent with state definitions
Previously the `state` marker for rules was in a weird position:
```catala
rule foo under condition bar
  consequence state st fulfilled
```

This patch unifies the syntax with definitions, now using instead:
```catala
rule foo state st
  under condition bar
  consequence fulfilled.
```
2023-03-08 15:17:58 +01:00
Louis Gesbert
42b8adb968 Add a duration / duration overload
Interstingly enough, it was already implemented in the Python backend.

Required to implement *pro rata temporis*, which the US tax section 121 does
make use of.

Only allowed for durations expressed in days (as returned by `<date> - <date>`),
of course.
2023-03-08 15:17:58 +01:00
Denis Merigoux
1fe3987168
Formatting 2023-03-05 12:10:04 +01:00
Louis Gesbert
5398b1037f Fix ill-funded order function on desugared vars 2023-03-03 19:22:17 +01:00
Louis Gesbert
97e0cfca6f Improvements on function arguments refactoring
- simplify naming in the french law examples
- make messages yet more precise on function arguments mismatch
2023-03-02 19:11:21 +01:00
Louis Gesbert
3766e9db2c Fix function argument naming consistency in the examples 2023-02-28 16:17:19 +01:00
Louis Gesbert
fc5910e093 Fix multi-argument scopedefs, improve error message positions
This adds a few positions to the parser, and tweaks some others, vastly
improving the reporting of some errors (inconsistent functions definitions, but
also exceptions cycles, etc.)
2023-02-28 15:53:50 +01:00
Louis Gesbert
2c97d5de14 Enforce consistency of function arguments naming 2023-02-28 15:53:50 +01:00
Louis Gesbert
8200457e43 Syntax change: require declaration of function argument names 2023-02-28 15:53:50 +01:00
Louis Gesbert
5bd140ae5f
Arrow List (#404) 2023-02-22 14:06:55 +01:00
adelaett
4f029db47b explicitly don't accept multiple arguments from surface to desugared 2023-02-22 12:21:55 +01:00
adelaett
9f31715a47 style 2023-02-22 12:11:42 +01:00
adelaett
8553b9dd7e Alternative printing of type TArrow
Changed the typing printing in the pretty printer to:
* () -> unit for empty lists
* a -> b for single elements lists
* (a, b, c, d) -> b for multiple elements lists
2023-02-22 11:52:22 +01:00
adelaett
bd0243359e changed the invariant documentation of scopelang -> dcalc
Since functions inside catala can now have multiple arguments (while
not yet being user-definable) the invariant is now about partial
evaluation not being possible.
2023-02-22 11:42:48 +01:00
adelaett
576f21f69c Added documentation for encoding constructors in the typing inference 2023-02-22 11:41:21 +01:00
adelaett
51b5ccb08e change operator definition style to something more readable 2023-02-22 11:40:22 +01:00
adelaett
a4466fecc7 fixed some mixup in Format.fprintf arguments 2023-02-21 16:19:17 +01:00
adelaett
99d82bc33e Fix toplevel type definition (if arg_types is [], then use a different way) 2023-02-21 14:17:24 +01:00
adelaett
b512dc6ec7 Fix List.combine internal error (create multiple TAny instead of only one) 2023-02-21 14:16:50 +01:00