Commit Graph

232 Commits

Author SHA1 Message Date
vbot
601dc80e3d
Add the possibility to override inputs of included files 2024-09-11 14:46:32 +02:00
Louis Gesbert
acc13867bf Fix: return module items in file order
This affects their UIDs, and the order in which they later get traversed.

In particular, it was affecting the struct names renaming.
2024-08-28 17:18:26 +02:00
vbot
7f4824bed6
adapt existing errors to changes 2024-07-31 14:01:55 +02:00
Louis Gesbert
2471c60beb Update some dependencies
- more recent sedlex fixes a bug that needed a workaround in our code
- we need recent dates_calc to avoid extra runtime dependency on `Str` that our
  build system won't handle
2024-06-26 12:37:57 +02:00
vbot
441dd54ec3
Refactor suggestions 2024-06-20 15:59:54 +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
4a44698fe7
Add multiple parsing error support 2024-06-17 15:38:33 +02:00
Louis Gesbert
f04e889173 Pass the "external module" info along passes 2024-05-28 11:43:50 +02:00
Louis Gesbert
33ce233a29 Fix lexing of verbatim blocks
Catala doesn't interpret them at all, but it needs to refrain from interpreting
its contents as markdown (titles, etc.)
2024-05-16 15:46:39 +02:00
Louis Gesbert
1cf34d9123 Fix formatting of syntax error messages 2024-05-08 12:36:56 +02:00
Louis Gesbert
4d412027d0 Remove direct dependency towards dates_calc from the compiler
The dependency should only go through the `Runtime` module
2024-05-02 16:30:46 +02:00
Louis Gesbert
cee8e57d02 More precise positions for operators throughout 2024-04-30 16:35:08 +02:00
Louis Gesbert
eded54d2b5 Support for direct tuple member access
As discussed in #549

NOTE: This implements only the direct tuple member access (syntax `foo.N` with N a
number)

- It seems more efficient to wait for the general pattern-matching rewrite to
  handle pattern-matching on tuples
- Until then we keep the (now obsolete) `let (x, y) = pair in x` syntax, to
  leave time for updates, but we won't be documenting it
2024-04-13 09:37:03 +02:00
Louis Gesbert
a61ae7979f
Support for structure updates
Closes #592

A new node is added in `desugared`, and translated into an exploded structure
literal during translation to `scopelang`. The main reason to put it there is
that it needs to be after disambiguation, since that is used to discover the
type of the structure that is being updated.
2024-04-12 17:17:48 +02:00
Louis Gesbert
b78cd9c29a
Improve message formatting throughout
Ensuring messages don't print overlong lines still requires some manual work:
- if they don't contain any `Format` directives (`%` or `@`), use `"%a"
  Format.pp_print_text` to turn word-wrapping on.
- otherwise replace spaces with `@ ` to mark possible cutting points, as soon
  that it's possible the line will get over 80 chars (most often, this means
  starting before the first `%a`)
2024-04-12 17:07:36 +02:00
Louis Gesbert
def10e7f98 Message: further simplification 2024-04-10 19:26:23 +02:00
Louis Gesbert
98fc97a241 Rewriting message calls to use the new intf 2024-04-10 19:26:23 +02:00
Louis Gesbert
0ec04c4925 Branch cleanup and test outputs update
Lots of tests have a new warning because they were calling subscopes without
using their outputs. A better solution could be to mark these subscopes as
`output`, now that it's possible !
2024-04-04 10:55:21 +02:00
Louis Gesbert
eeaadef27c Output subscopes: implement syntax
required a little generalisation and explicit parsing errors to avoid conflicts,
but it remains reasonable
2024-04-04 10:24:18 +02:00
Louis Gesbert
619cafebb8 Reformat 2024-03-20 14:41:06 +01:00
Louis Gesbert
1a17098297 Move file functions that were in Cli to File
it's now possible because Globals where moved away
2024-03-19 15:26:32 +01:00
Louis Gesbert
4cec981f62 Move global options of Cli to their own module
This resolves a dependency cycle that would forbid `Cli` from using the modue
`File`, which was annoying.
2024-03-19 15:18:35 +01:00
Louis Gesbert
99004ab1d9 catala depends fixes
- automatically include the directories of listed files
- work for files that don't define modules
2024-03-13 18:15:50 +01:00
Louis Gesbert
2f2924944a Syntax: add keywords in front of list filtering / arg-extremum
Closes #574
2024-02-14 13:55:03 +01:00
Louis Gesbert
bf0ef0b1f5 Allow access to intermediate variable states
Through the syntax `var_name state state_name`.

Addresses #567, but
- requires documentation
- explicitely accessing states of the variable being defined is not allowed at
  the moment (warning proposed in #567 requires a whole-expression check, which
  is better done some place else entirely)
2024-02-12 18:15:48 +01:00
Denis Merigoux
a033f02689
Restore tests 2024-01-29 11:06:48 +01:00
Louis Gesbert
371f9554b8 Support for list recombinations
The primary use-case for this was to be able to run computations on a list of
structures, then return an updated list with some fields in the structures
modified : that is what we need for distribution of tax amounts among household
members, for example.

This patch has a few components:

- Addition of a test as an example for tax distributions

- Added a transformation, performed during desugaring, that -- where lists are
  syntactically expected, i.e. after the `among` keyword -- turns a (syntactic)
  tuple of lists into a list of tuples ("zipping" the lists)

- Arg-extremum transformation was also fixed to use an intermediate list instead
  of computing the predicate twice

- For convenience, allow to bind multiple variables in most* list
  operations (previously only `let in` and functions allowed it)

- Fixed the printer for tuples to differentiate them from lists

*Note: tuples are not yet allowed on the left-hand side of filters and
arg-extremums for annoying syntax conflict reasons.
2024-01-26 11:29:33 +01:00
Louis Gesbert
94ebc1b65e Allow deconstruction of tuples using let in 2023-12-19 17:25:44 +01:00
Louis Gesbert
df3ab64fe9 Add tuples to the surface language
No helpers to destruct them at the moment
2023-12-19 17:25:44 +01:00
Louis Gesbert
e123d7eb95 Change type syntax of collection into list of 2023-12-19 15:26:44 +01:00
Louis Gesbert
9a255522be Document and first test for externals
Also some fixes for Clerk to properly support them
2023-12-06 11:06:54 +01:00
Louis Gesbert
e689f0c47b Small cleanup and doc on the module handling refactor 2023-12-05 16:01:56 +01:00
Louis Gesbert
1ae955b504 Reformat 2023-11-30 23:53:38 +01:00
Louis Gesbert
8df49dcea2 More tests and some fixes 2023-11-30 23:49:19 +01:00
Louis Gesbert
3649f92975 Rework resolution of module elements
This changes the `decl_ctx` to be toplevel only, with flattened references to
uids for most elements. The module hierarchy, which is still useful in a few
places, is kept separately.

Module names are also changed to UIDs early on, and support for module aliases
has been added (needs testing).

This resolves some issues with lookup, and should be much more robust, as well
as more convenient for most lookups.

The `decl_ctx` was also extended for string ident lookups, which avoids having
to keep the desugared resolution structure available throughout the compilation
chain.
2023-11-30 21:14:12 +01:00
Louis Gesbert
3b0e576a24 Fix module name propagation 2023-10-13 16:13:02 +02:00
Louis Gesbert
263cf3a9f7 Fix line-lexer on french syntax
"Usage de" being two words was tripping it
2023-10-03 18:49:16 +02:00
Louis Gesbert
cc7c3fc18c Clerk: add more tests, and small fixes 2023-10-02 17:51:16 +02:00
Louis Gesbert
a79acd1fa8 Reformat 2023-09-27 13:19:04 +02:00
Louis Gesbert
5efa61a0ce Clerk: rewrite 'clerk runtest' to use the new lightweight lexer
* Obsolete code for included tests has been removed

* The engine uses a proper lexer and is much simplified

* An inline test in the middle of the file now only "sees" the file up to that
  point. This fixes an issue where we had spurious errors when a type error was
  added at the end of a file, and it would pop up in tests before it. This makes
  files including many tests much more practical.

* diffing and resetting the tests has been reintroduced (done at the moment in
  Ninja, but for more control (count number of failed tests, etc.) we could put it
  back into Clerk at some point

* The Catala CLI can now take an input from stdin (with the possibility to link
  a (possibly fake) on-disk file for error reporting and file locations ; this
  is useful for running tests)
2023-09-27 13:18:18 +02:00
Louis Gesbert
dbe0990163 Rework module includes CLI in Catala
Rather than require all files to be listed on the command-line (and having to
check consistency with `> Using` directives), the main catala CLI is now a bit
more clever.

⇒ There is a new assumption that a module name definition must match the file
name (up to case and extension) — with appropriate error handling to enforce it.

In exchange, `> Using` directives are now used to more transparently lookup the
appropriate `.catala_*` interfaces and the compiled artifacts for the used modules (handling transitive dependencies), with just standard `-I` flags for when they need to be looked up in different places.
2023-09-27 13:14:40 +02:00
Louis Gesbert
4bce4e6322 Reformat 2023-09-27 13:14:38 +02:00
Louis Gesbert
f162f6e9bd Improve handling of module name definitions
and add some sanity-checks for consistency of used modules w.r.t. actually
loaded modules.
2023-09-27 13:14:03 +02:00
Louis Gesbert
22c69938b6 Fix handling of "output" tests
I.e. our legacy tests with a separate output tests, to distinguish from inline
tests.
2023-09-27 13:08:15 +02:00
Louis Gesbert
494be673a8 Rehaul the Clerk build system to fully handle modules and linking 2023-09-27 13:08:15 +02:00
Louis Gesbert
bf048f0a74 Add a lightweight lexer for dependency extraction in Clerk
The base is there but not fully used yet in Clerk
2023-09-27 13:08:15 +02:00
Louis Gesbert
9aed2c7479 support for parsing Module directives 2023-09-27 13:08:11 +02:00
Denis Merigoux
9cecf5587a
Register surface syntax languge in program troughout the compilation chain 2023-09-22 18:05:26 +02:00
Louis Gesbert
3cc77f4601
Improvements to the Polish translation (#499) 2023-09-13 16:19:06 +02:00
Denis Merigoux
c1d4592998 Correct MR_* fields for characters with accents 2023-09-13 14:14:47 +02:00