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.
- Clearly distinguish Exceptions from Errors. The only catchable exception
available in our AST is `EmptyError`, so the corresponding nodes are made less
generic, and a node `FatalError` is added
- Runtime errors are defined as a specific type in the OCaml runtime, with a
carrier exception and printing functions. These are used throughout, and
consistently by the interpreter. They always carry a position, that can be
converted to be printed with the fancy compiler location printer, or in a
simpler way from the backends.
- All operators that might be subject to an error take a position as argument,
in order to print an informative message without relying on backtraces from
the backend
Use xelatex and don't require fonts-extra (which is 1GB) just for two 20-lines
files.
This also syncs the dependencies for the cheat-sheets which those of Catala
literate output, which is good.
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.
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
... that's one less thing to do
Two notes:
- Updated the syntax errors in
examples/NSW_community_gaming/tests/test_nsw_social_housie.catala_en ; those
probably aren't expected though, but fixing them is outside my purpose here
- There is consensus on keeping the error messages in English; however, here,
the error messages include hints on the syntax to use, which are only valid
for users of the English syntax.
* A possible solution would be to apply cppo on parser.messages, using the
macros already defined in lexer_LANG.cppo.ml. However, we would then need to
tweak (or duplicate!) the parser to use the messages for the correct language.
Furthermore, updating and merging the file on parser updates would need
special care.
* Another, maybe easier solution would be manual processing, using a custom
escape in the parser messages and rewriting that at runtime when printing
the message. We would need to extract a runtime version of the macro
definitions though.