Commit Graph

485 Commits

Author SHA1 Message Date
Louis Gesbert
fe2c66af12 Select colors for Uids upon instanciation
This way different Uid kinds will have a consistent color across error messages,
AST dumps, etc.
2023-09-01 14:41:56 +02:00
Louis Gesbert
ce97b55c27 Update tests 2023-08-31 18:31:48 +02:00
Louis Gesbert
544e18e110 Fixes related to environments and lookups 2023-08-31 18:31:48 +02:00
Louis Gesbert
7db63e5f78 Simplification: store paths in Uids
rather than scattered in structures

The context is still hierarchical for defs though, so one needs to retrieve the
path to lookup in the correct context for info. Exceptions are enums and struct
defs, which are re-exposed at toplevel.
2023-08-31 18:31:48 +02:00
Louis Gesbert
b5baa91a2e Add (half-baked) test on module usage
Half-baked because clerk doesn't know to order the tests properly at the moment,
and we spit compiled files into the source test directory.
2023-08-31 18:31:48 +02:00
Louis Gesbert
9bac045d03 Implement module lookups for scopes, structs, and enums 2023-08-31 17:54:39 +02:00
Louis Gesbert
edd6dce0d8 Disable recursive tests reset for now; remove rel paths in test out 2023-08-04 12:08:18 +02:00
Louis Gesbert
378669b09e Implement reversing the dependencies for tests
This works for the `--reset` option, but I have some doubts about it.
2023-08-04 12:08:18 +02:00
Aminata-Dev
94f8eac858 Better indications for the user :
- We're able to say from the parser what the user could have written. It may not be complete due to the acceptable function of Menhir : it is only an indication given to the user (and not intended to be an adaptive documentation)
- .mli file added : module interface for suggestions
- Add a test that provides a typographical or a logical error.
- Documentation and type / name changes for suggestions
2023-07-12 16:32:55 +02:00
Louis Gesbert
c96c6e187f Re-implement the GNU message output format 2023-07-12 13:57:58 +02:00
Aminata-Dev
b0d16c1a58 Tests updated 2023-07-12 11:55:11 +02:00
Aminata-Dev
b087ca4f47 Improve suggestions
- Improved implementation of suggestions (suggestion_minimum_levenshtein_distance_association > suggestions.ml)
- Magnifying glass emoji added for suggestions
- Improve display by...
	- Fixing "Pos.ml" (pretty-printing box not closed)
	- Remove unnecessary spaces
- compiler/surface/parserdriver.ml
	- Optionnal suggestions added when raising a parser error
	- Function "levenshtein_distance" removed and replaced by "Suggestions.levenshtein_distance"
- Tests updated (mostly line breaks and spacing changes)
- Variable names renamed for greater clarity
- (Based on commit 0813f5c36e)
2023-07-12 11:55:11 +02:00
Aminata-Dev
75b6251b43 Match the compiler code to the new type of error message content 2023-07-12 11:55:11 +02:00
Denis Merigoux
50113586e3 With @aminata-dev update Messages.Content 2023-07-12 11:55:11 +02:00
Denis Merigoux
4cdd2fce0f With @aminata-dev, implemented first error message improvement! 2023-07-12 11:55:11 +02:00
Louis Gesbert
db34c9a848 Generalise the expression printer
This patch functorises the generic expression printer, in order to be able to
re-use it for end-user printing.

It makes it possible to have an end-user, localised printer that shares the code
for e.g. priority and automatic parens handling.

A generic AST rewriting that disambiguates variables (very simple to write with
bindlib) is also added and used in the OCaml backend for something safer than
just appending `_user` (-- this also handles clashing variables that could be
introduced during compilation which would have generated wrong code before this)

Finally, the `explain` plugin is adapted to use the new printer.

Ah, and `String.format_t` was tweaked to correctly print strings that might
contain unicode without breaking alignment, and should be used instead of
`format_string` or `%s` whenever unicode can be expected.
2023-07-11 17:33:56 +02:00
Louis Gesbert
3cb8fc1499 Tweak printing of if/then/else 2023-07-10 15:48:11 +02:00
Louis Gesbert
98f712365e Restore full expression printing when --debug is set 2023-07-03 17:30:17 +02:00
Louis Gesbert
89e90271c1 Implement an additional localised, user-facing value printer 2023-07-03 16:42:54 +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
b55d8c823b Closure conversion & hoisting working 2023-06-18 21:30:55 +02:00
Denis Merigoux
a20adc0055 Closure hoisting (missing a bug on hardest case) 2023-06-18 18:08:18 +02:00
Denis Merigoux
9cf55b0edd Closure env is unit if no extra variable captured 2023-06-18 15:49:02 +02:00
Louis Gesbert
e224e87f71 Wip support for modules
(first working dynload test with compilation done by manual calls to ocaml)

A few pieces of the puzzle:

* Loading of interfaces only from Catala files
* Registration of toplevel values in modules compiled to OCaml, to allow access
  using dynlink
* Shady conversion from OCaml runtime values to/from Catala expressions, to
  allow interop (ffi) of compiled modules and the interpreter
2023-06-15 17:56:57 +02:00
Denis Merigoux
ed2891c761
Closure conversion should work now 2023-06-15 17:32:00 +02:00
Denis Merigoux
571c7c5d89
Correctly count number of var occurences 2023-06-14 11:39:27 +02:00
Denis Merigoux
42aaa1017d
Created minimal not working example and tame down beta-reduction 2023-06-14 11:18:39 +02:00
Denis Merigoux
2c9b56fb70
More agressive re-typing 2023-06-13 20:37:23 +02:00
Denis Merigoux
27bbe78438
Understanding a limitation 2023-06-13 20:10:42 +02:00
Denis Merigoux
7072369b2d
Starting to work 2023-06-13 11:43:13 +02:00
Denis Merigoux
926c9436e3
Fix some bugs 2023-06-13 11:15:32 +02:00
Denis Merigoux
0e99d1598b
Continue closure conversion 2023-06-13 10:49:46 +02:00
Denis Merigoux
84350b1593
Better typing error message 2023-06-13 09:07:42 +02:00
Denis Merigoux
45375dd7b5
Fix a bug in closure conversion 2023-06-12 15:21:06 +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
Denis Merigoux
d1a836c646 Removing less precise message 2023-06-03 18:04:41 +02:00
Denis Merigoux
09bcefbcc1 Update tests 2023-06-03 18:02:57 +02:00
Denis Merigoux
5d765676b5 Format rather than print 2023-06-02 10:58:03 +02:00
Denis Merigoux
579e66a500 Restore testing (formatting is better!) 2023-06-02 10:50:33 +02:00
Denis Merigoux
eec5ae54c6
Fixed formatting -> tests update 2023-05-04 19:18:53 +02:00
Denis Merigoux
bcd91f5dea
Merge branch 'master' into aides_logement_outre_mer 2023-05-04 11:04:28 +02:00
Louis Gesbert
5e26c5c83d Yet more printer improvements
- Fix the printer for scopes
- Improve the printer for struct types
- Remove `Print.expr'`. Use `Expr.format` as the function with simplified arguments instead.
2023-05-02 16:33:23 +02:00
Louis Gesbert
83e7a845fe Cleanup expr printer interface
- `Print.expr` no longer needs the context
- This removes the need for `expr ~debug` + `expr_debug` ;
  use `Print.expr` for normal (non-debug) output,
  and `Print.expr' ?debug ()` for possibly debug output.
- This improves consistency of debug expr output in many places
- Prints simplified operators (without type suffix) in non-verbose mode

(this patch also fixes some cases of `Expr.skip_wrappers` and leverages the
binder equality provided by Bindlib)
2023-05-02 13:32:16 +02:00
Louis Gesbert
c249cef3cc Printer: flatten nested let-ins too 2023-05-02 11:53:30 +02:00
Louis Gesbert
3e7a2a34ab More printer improvements 2023-05-02 11:49:09 +02:00
Denis Merigoux
c6bafe8896
Update assets and tests 2023-05-02 10:58:45 +02:00
Denis Merigoux
7788bf9e73
Error message when two same states 2023-04-27 15:37:11 +02:00
Denis Merigoux
9b056f3ca1
Update assets and fix errors after rebase 2023-04-27 12:18:50 +02:00