Commit Graph

202 Commits

Author SHA1 Message Date
vbot
5f57f4bf76
Message: also notify warnings to LSP 2024-11-04 16:45:55 +01:00
Louis Gesbert
4dc049f784
Mostly graphical improvements to the explain plugin (#733) 2024-10-31 14:39:33 +01:00
Louis Gesbert
57f85ffb9c Fix non-identchars appearing in backend idents 2024-10-30 14:15:56 +01:00
vbot
26875d24ad
Ast: add binders positions to EAbs 2024-10-28 17:45:18 +01:00
vbot
ec4c1a260e
Globals: add an LSP message format kind 2024-10-15 12:10:16 +02:00
vbot
2754bc33d5
Utils: refactor gnu pretty-printing 2024-10-15 12:03:21 +02:00
Louis Gesbert
c805f41da4
Add --autotest option (#706) 2024-10-03 13:15:51 +02:00
Denis Merigoux
08cec1b104
Add a catch to error raised by get_command 2024-10-02 11:33:07 +02:00
Louis Gesbert
543dd243c9 Add support for automatic instrumentation with assertions
This adds a `--autotest` flag. Quoting the (new) manpage section:

> Insert automatic test assertions in the compiled program. This
> detects all scopes that have no input or context variables, runs
> the interpreter to pre-compute their values, then adds runtime
> assertions to the program that ensure that the actual output of the
> scopes match their pre-computed values. If used on a testing
> program with a given backend, this guarantees consistency between
> the backend and the interpreter.
2024-10-01 15:03:31 +02:00
Louis Gesbert
0f409dd9af
Progress on the C backend (#671) 2024-09-26 10:00:04 +02:00
vbot
a79f272fc5
Add map_info to UIds 2024-09-24 17:37:59 +02:00
Louis Gesbert
ea0ab3ccf9 Clerk: consistent capitalisation of module filenames
now all artefacts related to the module Foo are capitalised, like the module
name.
2024-09-23 16:29:36 +02:00
Louis Gesbert
dd6ef8bcce C backend: first module handling proto using raw #include 2024-09-17 14:47:27 +02:00
Louis Gesbert
5ca37029a8 C backend: qualify definitions with module name 2024-09-17 11:51:45 +02:00
Louis Gesbert
cb88cb07a1 Reformat 2024-09-02 13:54:29 +02:00
Louis Gesbert
e97f2dd092 Fixes to renamings, scalc and C backend 2024-09-02 13:54:27 +02:00
Louis Gesbert
a971260cab Closure conversion: restore non-transformation of higher order ops under a flag
by reusing the `--keep-special-ops` flag
2024-08-30 15:36:25 +02:00
Louis Gesbert
9450e3a3f7 Manpage improvements
- add Vincent as author
- print the full man-page for subcommands (including authors, bugreports, etc.)
- separate debugging commands in a separate section (e.g. the *calc commands)
2024-08-30 15:36:25 +02:00
Louis Gesbert
7819a0a855 Python backend: fix handling of operations that can raise 2024-08-30 15:36:24 +02:00
Louis Gesbert
dd7b21bd20 Fix: avoid hard failure on position printing when file changed
Note: we don't really detect the changes, maybe a hash could help; but at least
this avoids an ugly `Index out of bounds` in the case where the changes caused
a line to be shorter than expected.
2024-08-30 15:35:52 +02:00
Louis Gesbert
da101ea612 Implement lifting of positions at the scalc level
and remove special handling from the backends (in particular, lifting in the C backend)
2024-08-30 15:35:47 +02:00
Louis Gesbert
7def9a20f4 Merge commit origin/master into crun 2024-08-30 15:27:01 +02:00
Louis Gesbert
b9156bb60e Implement safe renaming of idents for backend printing
Previously we had some heuristics in the backends trying to achieve this with a
lot of holes ; this should be much more solid, relying on `Bindlib` to do the
correct renamings.

**Note1**: it's not plugged into the backends other than OCaml at the moment.

**Note2**: the related, obsolete heuristics haven't been cleaned out yet

**Note3**: we conservatively suppose a single namespace at the moment. This is
required for e.g. Python, but it forces vars named like struct fields to be
renamed, which is more verbose in e.g. OCaml. The renaming engine could be
improved to support different namespaces, with a way to select how to route the
different kinds of identifiers into them.

Similarly, customisation for what needs to be uppercase or lowercase is not
available yet.

**Note4**: besides excluding keywords, we should also be careful to exclude (or
namespace):
- the idents used in the runtime (e.g. `o_add_int_int`)
- the dynamically generated idents (e.g. `embed_*`)

**Note5**: module names themselves aren't handled yet. The reason is that they
must be discoverable by the user, and even need to match the filenames, etc. In
other words, imagine that `Mod` is a keyword in the target language. You can't
rename a module called `Mod` to `Mod1` without knowing the whole module context,
because that would destroy the mapping for a module already called `Mod1`.

A reliable solution would be to translate all module names to e.g.
`CatalaModule_*`, which we can assume will never conflict with any built-in, and
forbid idents starting with that prefix. We may also want to restrict their
names to ASCII ? Currently we use a projection, but what if I have two modules
called `Là` and `La` ?
2024-08-28 17:18:26 +02:00
Louis Gesbert
8405301632 Reformat 2024-08-09 12:24:34 +02:00
Louis Gesbert
edb8db9ada Implement expansion of equality tests
This adds an optional pass that recursively expands equality tests across
structures and enums, on lcalc.

NOTE: this is a temporary solution.

- all tests are completely inlined, which may be a bit bloated
- due to the lack of primitives (and expressive pattern-matching), checking
  equality on enums generates a 2-level pattern matching, quadratic in the
  number of constructors
- this is completely separate from the monomorphisation pass, which morally
  should take care of generating this code (as specific functions rather
  than inlined code)

So, while this should work as a place-holder for now, it actually seems more
reasonable mid-term (before we do it through monomorphisation) to do this
translation at the backend level, i.e. when generating the C code, when we have
full access to the representation of enums.
2024-08-09 11:54:34 +02:00
Louis Gesbert
1f739d6d89 C backend: Lift position declarations
It's more tidy, and was required anyway for e.g. division operators
2024-08-09 11:47:45 +02:00
vbot
e062124e47
fix typing error missing position 2024-08-06 16:17:43 +02:00
vbot
f5b9e5df2d
fix position invalid test 2024-07-31 14:01:56 +02:00
vbot
c83e247d5d
add lsp error notification mechanism 2024-07-31 12:13:49 +02:00
Louis Gesbert
561788cbaf Fix formatting of debug timing markers 2024-07-04 15:08:13 +02:00
Louis Gesbert
583e80993a Remove the with-exceptions backend
*Disclaimer*: This is intended for discussion

My impression is that the with-exceptions backend is to be superseded by the
without-exception backend, which is more general and more efficient. Therefore,
seeing the added complexity of maintaining the two in parallel, I see no good
reason to keep the with-exceptions version now that the equivalence of their
semantics have been proved.

It will also be nice to reduce divergences between the different backends ; and
this should make further simplifications possible (e.g. some thunkings may no
longer be needed)

Of course I am ready to hear arguments in favor of keeping it, be it in the mid-
or long-term.

This patch removes the `--avoid-exceptions` flag, making it the only option, and
the corresponding `with_exceptions` variant of the dcalc->lcalc translation. It
doesn't do further simplifications.
2024-07-04 15:08:13 +02:00
Louis Gesbert
cdb31ffd57
Support for basic clerk.toml configuration files (#639) 2024-07-01 15:40:06 +02:00
Louis Gesbert
81e2d18100 Don't try to read screen columns without a tty 2024-06-27 13:59:25 +02:00
Louis Gesbert
05752988e6 Clerk: add support for basic configuration files
Not much there at the moment, but being able to specify the include directories
is already pretty useful to run clerk directly e.g. on `catala-examples`.

(you had to explicitely specify variable `CATALA_INCLUDE`, the `-I` flags or to
go through `make` without that)
2024-06-26 10:41:12 +02:00
Louis Gesbert
38a93424a8 Clerk reports: postprocess diff output
This relies less on specific color flags of GNU diff, and reformats and
colorises the output.
(it may still depend on the specific layout of GNU diff with the `-y` flag
though)
2024-06-21 18:19:09 +02:00
Louis Gesbert
8881fee37f Allow catala ocaml --closure-conversion
it's probably not useful per se, but will be handy for debugging
2024-06-21 12:23:01 +02:00
vbot
c26d3fdf4a
Refactor and improve suggestions' pretty-printing 2024-06-21 11:11:53 +02:00
vbot
441dd54ec3
Refactor suggestions 2024-06-20 15:59:54 +02:00
vbot
435794d70a
Add error messages numbering (#634) 2024-06-20 15:41:55 +02:00
Louis Gesbert
ad15984d0b More space between multiple errors, no numbers if just one 2024-06-20 11:15:53 +02:00
vbot
a7094fe52d
Add messages numbering 2024-06-19 18:06:03 +02:00
Louis Gesbert
80400d838a
Messages: improve string padding processing 2024-06-19 16:10:26 +02:00
Louis Gesbert
45b0feaf20
Generate tests reports from 'clerk test'
This is a proper replacement for the previous shell-based placeholder hack.

Here is a summary:

- `clerk runtest` (normally run by ninja) is much extended:
  * besides generating the test@out file, it checks individual tests for success
    and can write a report file containing their status, and the positions for
    their (expected/current) outputs (this uses `Marshal`)
  * it now handles out-tests directly in addition to inline-tests, for which
    it generates the separate output file ; they are included in the report

- ninja is now tasked with building all the test reports (which shouldn't fail);
  for directories, individual reports are concatenated (as before).
  Removing intermediate report rules, and out-test rules means that the ninja
  file is much simplified.

- then, clerk takes back control, reads the final reports and formats them in a
  user-friendly way. Printing the reports may imply running `diff` internally.
  In particular, the commands to easily reproduce each test are provided.
  Resetting the test results if required is also done directly by clerk, at this
  stage.

A few switches are available to customise the output, but I am waiting for some
feedback before deciding what to make available from the CLI.

The `clerk report` command is available to manually explore test reports, but
normally the processing is done directly at the end of `clerk test` (i.e. ninja
will no longer call that command)
2024-06-19 16:10:26 +02:00
vbot
9622ac4172
Add an option to stop on the first delayed error encountered 2024-06-19 14:52:32 +02:00
vbot
62470d0db8
Replace failwith by internal errors 2024-06-18 16:28:20 +02:00
vbot
421d281fc1
Add delayed errors in Message 2024-06-17 15:36:38 +02:00
Louis Gesbert
db87409125 Replace module hashes for external modules
NOTE: This is a temporary solution

A future approach could be to have Catala generate a module loader (with the
proper hash), relieving the user implementation from having to do the
registration.
2024-05-28 11:43:50 +02:00
Louis Gesbert
709b51beb6 Fix hashing of submodule references 2024-05-28 11:43:50 +02:00
Louis Gesbert
403156b36e Computation and checking of module hashes
This includes a few separate changes:

- pass visibility information of declarations (depending on wether the
  declaration was in a ```catala-metadata block or not)

- add reasonable hash computation functions to discriminate the interfaces. In
  particular:
  * Uids have a `hash` function that depends on their string, but not on their
    actual uid (which is not stable between runs of the compiler) ; the existing
    `hash` function and its uses have been renamed to `id`.
  * The `Hash` module provides the tools to properly combine hashes, etc. While
    we rely on `Hashtbl.hash` for the atoms, we take care not to use it on any
    recursive structure (it relies on a bounded traversal).

- insert the hashes in the artefacts, and properly check and report those (for
  OCaml)

**Remains to do**:

- Record and check the hashes in the other backends

- Provide a way to get stable inline-test outputs in the presence of module
  hashes

- Provide a way to write external modules that don't break at every Catala
  update.
2024-05-28 11:43:50 +02:00
Louis Gesbert
3d1e9a56bf Fix adjustment of format width to terminal 2024-05-06 21:39:58 +02:00