Commit Graph

173 Commits

Author SHA1 Message Date
Louis Gesbert
f9e3964621 Add an explain plugin
Based on the lazy_interp plugin, this new plugin generates a `dot` graph
retracing a given computation from source definitions to the results.
2023-07-11 17:33:56 +02:00
Louis Gesbert
4ae949f7f8 Fix formatting of exception trees 2023-07-07 14:56:54 +02:00
Louis Gesbert
98f712365e Restore full expression printing when --debug is set 2023-07-03 17:30:17 +02:00
Louis Gesbert
0f9ee2c72e Refacter the main Driver module
- Use separate functions for successive passes in module `Driver.Passes`
- Use other functions for end results printing in module `Driver.Commands`

As a consequence, it is much more flexible to use by plugins or libs and we no
longer need the complex polymorphic variant parameter.

This patch leverages previous changes to use Cmdliner subcommands and
effectively specialises the flags of each Catala subcommand.

Other changes include:

- an attempt to normalise the generic options and reduce the number of global
  references. Some are ok, like `debug` ; some would better be further cleaned up,
  e.g. the ones used by Proof backend were moved to a `Proof.globals` module and
  need discussion. The printer no longer relies on the global languages and prints
  money amounts in an agnostic way.
- the plugin directory is automatically guessed and loaded even in dev setups.
  Plugins are shown by the main `catala` command and listed in `catala --help`
- exception catching at the toplevel has been refactored a bit as well; return
  codes are normalised to follow the manpage and avoid codes >= 128 that are
  generally reserved for shells.

Update tests
2023-07-03 16:42:54 +02:00
Denis Merigoux
5f48e5dac1
Merge branch 'master' into closure_conversion 2023-06-20 11:02:13 +02:00
Denis Merigoux
9007eb4204
Apply suggestions by @altgr 2023-06-19 17:29:51 +02:00
Louis Gesbert
52b1c25d50 Refactor CLI to use sub-commands
The upside of this is that each command can define specific flags ; there is a
small loss of backwards-compatibility in that the command needs to be the first
argument.

`catala --help` will now only show a summary of commands, with more specific
manpages shown on `catala CMD --help`.

Another point is that the plugin interface is extended to allow plugins to be
registered as subcommands and have their own flags (this will be very useful for
adding flags to the lazy/dot/explanation plugin that has many options).

Note that no efforts has yet been made to specialise the options, the previous
type was just made global for all subcommands.
2023-06-15 18:00:10 +02:00
Louis Gesbert
da59076223 Add a command-line option ('--use') for module linking 2023-06-15 17:58:46 +02:00
Denis Merigoux
6962761774
Merge branch 'master' into closure_conversion 2023-06-15 17:56:41 +02:00
Denis Merigoux
27bbe78438
Understanding a limitation 2023-06-13 20:10:42 +02:00
Aminata-Dev
10d147a8b1 Messages renamed to Message (lighter syntax) 2023-06-13 11:50:56 +02:00
Aminata-Dev
5f9cb55e34 s 2023-06-12 17:00:10 +02:00
Louis Gesbert
b975e7c149 Cleanup commented code 2023-06-09 15:28:12 +02:00
Louis Gesbert
e4c1216848 Tweak whitespace in messages 2023-06-08 14:36:28 +02:00
Louis Gesbert
fcadd9808e Update tests with whitespace changes 2023-06-08 14:03:08 +02:00
Louis Gesbert
11730ce271 Repair indentation of log messages 2023-06-08 13:34:54 +02:00
Louis Gesbert
c564e70636 Correctly setup ocolor on all output channels
(and some cleanup of the remaining deps to ANSITerminal)
2023-06-08 12:14:11 +02:00
Louis Gesbert
16c93fbb0c Reformat 2023-06-08 12:14:11 +02:00
Louis Gesbert
deaf40761e Use ocolor instead of ANSITerminal 2023-06-08 12:11:55 +02:00
Denis Merigoux
79801292e9
Fix most doc errors 2023-06-02 17:17:45 +02:00
Denis Merigoux
5d765676b5 Format rather than print 2023-06-02 10:58:03 +02:00
Denis Merigoux
d1210cc0e4 The thing compiles 2023-06-02 10:50:33 +02:00
Denis Merigoux
4e6efe08da All renamings done, on with actual refactor 2023-06-02 10:50:33 +02:00
Denis Merigoux
5f227933f3 Errors are now things to refactor [skip ci] 2023-06-02 10:50:33 +02:00
Denis Merigoux
0faa97b8fc Abstract messages interface 2023-06-02 10:50:29 +02:00
Louis Gesbert
fc531777c0 Rework and normalise the Marked interface
The module is renamed to `Mark`, and functions renamed to avoid redundancy:

`Marked.mark` is now `Mark.add`
`Marked.unmark` is now `Mark.remove`
`Marked.map_under_mark` is now simply `Mark.map`
etc.

`Marked.same_mark_as` is replaced by `Mark.copy`, but with the arguments
swapped (which seemed more convenient throughout)

Since a type `Mark.t` would indicate a mark, and to avoid confusion, the type
`Marked.t` is renamed to `Mark.ed` as a shorthand for `Mark.marked` ; this part
can easily be removed if that's too much quirkiness.
2023-05-17 17:37:00 +02:00
Denis Merigoux
eae61256ef
Adhere to the GNU standard for error messages 2023-05-04 19:19:19 +02:00
Denis Merigoux
a5d4f54115
Push some fixes suggested by @altgr 2023-05-04 18:28:24 +02:00
Denis Merigoux
4f7564b079
Improve editor parsable errors 2023-04-27 12:09:22 +02:00
Denis Merigoux
fcb5561b24
Coded message format adapted to editors 2023-04-27 12:09:22 +02:00
Denis Merigoux
2b0e18f5a8
Restore important flushing?! 2023-04-21 11:29:07 +02:00
Denis Merigoux
f877544368
Remove optimizations for big tests 2023-04-18 15:56:04 +02:00
Denis Merigoux
0ec75ad589
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-18 14:37:02 +02:00
Denis Merigoux
2afb6fc20c
I/O plumbing necessary for this feature, missing main implem 2023-04-18 09:59:24 +02:00
adelaett
02eeb4ad11
Include Bindlib_ext to Expr.Box 2023-04-14 14:18:28 +02:00
adelaett
622feec9a5
change Invariants choice to --check_invariants flag 2023-04-14 11:32:49 +02:00
adelaett
2ea67de397
typo 2023-04-14 11:21:52 +02:00
adelaett
a9809b69a9
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-14 11:19:58 +02:00
Louis Gesbert
e19e4af12d Vastly improve the printer
* fix lots of Format boxes
* add parens based on precedence in the printer
* fix interaction of Format and the colored line debug tags
2023-04-13 18:15:22 +02:00
adelaett
3e35d4b826
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-11 11:49:22 +02:00
adelaett
12d85570e8 fix printing boxes & merge issues 2023-04-07 10:51:21 +02:00
alain
ec40de83fc
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-06 13:57:22 +02:00
adelaett
5a3a6a9dc1 remove unused json ppx 2023-04-06 13:50:22 +02:00
adelaett
7b0f1b238c add documentation for interpret_lcalc 2023-04-06 13:09:49 +02:00
adelaett
72f6ac9f58 append lcalc to driver 2023-04-05 15:42:26 +02:00
Denis Merigoux
ad02a0959d
Merge branch 'master' into aides_logement_outre_mer 2023-04-03 14:12:10 +02:00
adelaett
685785eaa3 adding assert_closed function 2023-04-03 11:20:19 +02:00
adelaett
f897226ffb bindlib extension documentation 2023-04-03 10:57:52 +02:00
Denis Merigoux
6d71d52a2e
Update tests and create disable_warnings option 2023-03-31 16:43:03 +02:00
adelaett
beeecce091 correcting filter definition 2023-03-31 15:31:43 +02:00
adelaett
6dee3874cc Merge branch 'master' into adelaett-withoutexceptionsfix 2023-03-30 10:50:32 +02:00
Denis Merigoux
056e84792d
Printing warning for undefined variables 2023-03-17 09:25:14 +01:00
adelaett
82af9e8305 unfolding more bugs 2023-03-16 17:14:33 +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
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
adelaett
ba74bbc52a adding MapLabels and SetLabels to the standard Uid definitions. 2023-03-10 15:32:27 +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
adelaett
78f121b44a before any issues with mark on code_item 2023-03-03 11:39:55 +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
adelaett
631b6d77ff Revert "Abandoning json conversion :("
This reverts commit 02780f5439.
2023-02-28 08:37:50 +01:00
adelaett
02780f5439 Abandoning json conversion :( 2023-02-28 08:36:45 +01:00
adelaett
75dc978fa9 remove logs from the no_partial_evaluation invariant
removed error_on_empty when functions
2023-02-27 11:20:59 +01:00
adelaett
382150b513 new invariant option when launching the compiler 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
214bc55aae internal error message 2023-02-27 11:20:59 +01:00
Louis Gesbert
467a338b6c Install Catala plugins
Fixes #378

- the plugins are compiled as libraries rather than with `executable`, so that
  dune is able to install them
- they get installed to `lib/catala/plugins/<plugin-name>/<plugin-name>.cmxs`
- the lookup for plugins is now recursive to cope with the plugin subdirectories
  in the point above
2023-01-17 14:38:09 +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
c92fe5e72d Fix underline of code errors when code contains utf8 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