Commit Graph

560 Commits

Author SHA1 Message Date
Raphaël Monat
7021c41f93 Add date rounding option within scopes 2023-03-16 16:55:55 +01:00
Louis Gesbert
57e29f60bd
Refactor Python dep handling + update cheat-sheet (#419) 2023-03-03 11:05:56 +01:00
Louis Gesbert
5e063dac1b
Require argument name declarations, support multiple function arguments everywhere (#413) 2023-03-02 22:37:21 +01:00
Louis Gesbert
97e0cfca6f Improvements on function arguments refactoring
- simplify naming in the french law examples
- make messages yet more precise on function arguments mismatch
2023-03-02 19:11:21 +01:00
Louis Gesbert
84e6c70d66 Tutorial: fix overfull hbox 2023-03-02 14:32:07 +01:00
armand
9c176256fe Remplace la double préposition « de de » par « de » 2023-02-28 21:01:35 +01:00
Louis Gesbert
3766e9db2c Fix function argument naming consistency in the examples 2023-02-28 16:17:19 +01:00
Louis Gesbert
d3ccfe9b91 Adjust examples for the new function declaration syntax 2023-02-28 15:53:50 +01:00
Denis Merigoux
82141335c7
Tutorial: add top-level value definitions as an annex (#406) 2023-02-27 09:13:27 +01:00
armandsalek
ddb8361895
Merge branch 'CatalaLang:master' into master 2023-02-24 17:11:49 +01:00
Louis Gesbert
49b4f8a8d8 Tutorial: add top-level value definitions as an annex
The cheat-sheet still needs to be updated, I'll do that once we have a unified
syntax for function types and multiple arguments at the top-level and within
scopes.
2023-02-23 11:35:44 +01:00
armandsalek
f841512619
Update Makefile.common.mk
Ajout de l’appel à la variable « CURR_DIR » dans la définition de la règle « %.run »
2023-02-21 22:48:18 +01:00
Louis Gesbert
98ebc36343 Add all missing parser error messages
... 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.
2023-02-13 10:51:42 +01:00
Denis Merigoux
fcca9e4c47
Correction after confirmation from regulatory body 2023-01-20 10:10:31 -05:00
Louis Gesbert
19033669f5 Add support for paths in the parser
Using them will lead to "not supported yet" errors soon after, but it's a start
to get to handling separate modules.

The idea is that `foo` can now also be `Bar.foo`, `Bar.Baz.foo`, `foo.Struc.fld`
can be `foo.Bar.Baz.Struc.fld`, etc.
The next steps are to enable the lookups to handle this paths, and to provide
ways to load the external modules to feed these lookups.
2023-01-16 12:09:23 +01:00
Denis Merigoux
f4c92530c6
Update aides_logement and fix bugs to produce an updated working simulator (#377) 2023-01-13 12:05:32 +01:00
JusBanuls
6d05b2148e Retour à la ligne avec Alain 2023-01-12 17:14:35 +01:00
Denis Merigoux
c81c5c6708
Small bug spotted with the help of Justine 2023-01-10 11:55:23 +01:00
Denis Merigoux
d86eb8cb03
Ajout revalorisation plafond ASPA 2023 2023-01-10 11:47:14 +01:00
Denis Merigoux
bed7617581
Update smic 2023-01-07 20:53:05 +01:00
Denis Merigoux
fa84dd4330
Splitting long lines 2023-01-05 16:20:51 +01:00
Denis Merigoux
27cf705441
Update article 18 2023-01-04 16:30:14 +01:00
Denis Merigoux
b0e7e9faf8
Update art 15 2023-01-04 16:30:14 +01:00
Louis Gesbert
2003566867 Force parens in compound logic formulas
Closes #373

This forbids expressions such as `a and b or c`, avoiding the need to set an
implicit priority between `and`, `or` and `xor`, which I find error-prone.

Instead, when that appears, a message asking for explicit parentheses will be
shown to the user.

Implementation note: since that would be extremely tedious to do in the parser
directly, the parser is set to allow right-associativity without discrimination
for the logical operators, and the check is done during desugaring. This
required to explicit parentheses in the surface AST to discriminate the case
where the priority was explicit.
2023-01-04 10:46:14 +01:00
Louis Gesbert
92e925ace8
Syntax changes (#368) 2022-12-20 16:31:50 +01:00
Louis Gesbert
47502335aa Refactor the parser to use priorities
Define a single expression rule with disambiguation using token priorities
instead of the many layers of intermediate rules with explicit sub-terms.

Also replaces `in` for collection operations (`x+1 for foo in [1;2]`) with
`among` which helps a lot.
2022-12-19 15:12:53 +01:00
Matthew Gerrior
a58d98bce5
Fix typo in tutorial_en.catala_en
When working through the tutorial, I was thrown off a bit by this minor typo. The typo made it look like the tax calculation was subtracting the $10,000 exception from above, as opposed to the $100,000 from the bracket.
2022-12-18 15:38:19 -05:00
Louis Gesbert
f236e2cfb2 Replace the type conversion and rounding operators with overloads
Ref. #366

Also updates `CONTRIBUTING.md`.

This was pretty straight-forward :)
2022-12-13 15:32:49 +01:00
Louis Gesbert
c94509e0bb Remove integer division from the language
it's unlikely to be used in any law, and likely to be cause for confusion.

best of all, the new operator has a different return type, which
ensures no inconsistency with the change can get overlooked.
2022-12-13 12:35:02 +01:00
Louis Gesbert
dcb422302d Tests/examples update 2022-12-13 12:30:40 +01:00
Louis Gesbert
bb58d11ca8 Improve syntax for scope calls
implements #357
2022-12-13 12:30:38 +01:00
Louis Gesbert
09d49ab1cc French syntax: replace 'sortie' with 'résultat'
as per comment in #357
2022-12-13 12:27:33 +01:00
Louis Gesbert
4a66848eb3 Clarify some bits of the overload handling code
and address other remarks from the review of #365
2022-12-13 12:00:05 +01:00
Louis Gesbert
71bb67163c Remove explicitely typed operators in tests and examples
Command used: `sed -i 's/\([-+*/><=]=\?\)[.$@^€$]/\1/g' **/*/*.catala_*`

The overload test, of course, is kept unchanged and ensures that explicit
operators still work.
2022-12-13 12:00:04 +01:00
Louis Gesbert
b4adc33666 Update tutorial for overloads 2022-12-13 11:55:35 +01:00
Louis Gesbert
4ee4a96ac7 Remove *all* struct field access qualifiers in catala code
They are no longer needed \o/
2022-11-28 16:42:02 +01:00
Louis Gesbert
af2f5dbe19 Tweak error message location printing 2022-11-28 16:38:09 +01:00
Denis Merigoux
d7b9396e87
Correct lines 2022-11-24 15:17:00 +01:00
Denis Merigoux
b49e32cb59
Use scope calls in "Aides logement" (#352) 2022-11-07 16:18:03 +01:00
Louis Gesbert
a51d082033 Use scope calls in "Aides logement" 2022-11-07 14:23:10 +01:00
Louis Gesbert
4d4dac6727 Some fancy unicode for error outlines
Normally I would make sure this is not by default, or at leat disableable; but
here the code we print may contain utf8 anyway, so the terminal really needs to
support it. Anyway, it's just a little fancier, doesn't add much.
2022-11-07 14:13:01 +01:00
Louis Gesbert
429911024c Add parseable line-column info to error messages
a quick fix for now, ideally we want an option for editor-friendly output.
But for now this is a very cheap way to at least have clickable error messages
which are a big time-saver.
2022-11-07 14:03:38 +01:00
Louis Gesbert
48d788d744 Add tutorial section about direct scope calls
I am not convinced about this, would there be a better place where to put it?

My worry is that it could get confusing and should not be presented as "another
way to define subscopes", but it ended up a bit verbose.

There is also no section yet on "let-in" definitions, so I did not use them in
the example.
2022-10-25 12:28:51 +02:00
Louis Gesbert
b19a7660fc Fix ambiguities in examples 2022-10-21 17:36:44 +02:00
Louis Gesbert
5fc3181621 Aides logement: fix typo 2022-10-11 17:38:31 +02:00
Louis Gesbert
8c1696d0ff Inline tests: cleanup trailing whitespace 2022-09-23 16:56:21 +02:00
Louis Gesbert
0c0ef1ae1a Add test return codes
Simply re-generated with 'make tests CLERK_OPTS=--reset'
2022-09-23 14:50:02 +02:00
Louis Gesbert
0ab7a0f9ce Turn all existing tests to inline tests
Done using
```bash
process() { FILE=$1; awk 'match($0, /^```catala-test *{ *id *= *"(.*)" *}/, a) {print "```catala-test-inline"; f="'"$(dirname $FILE)/output/$(basename $FILE)"'." a[1]; getline; print "$ " $0; while ((getline<f) > 0) print; next} {print}' $FILE >$FILE.new; mv $FILE.new $FILE; }
for f in tests/test_*/*/*.catala_* examples/**/*.catala_*; do process $f; git add $f; done
for d in $(find -name output -type d); do git rm -r $d; done
```
2022-09-23 14:45:10 +02:00
Denis Merigoux
6e64f769a0
Update assets and rename executable 2022-09-08 15:16:39 +02:00
Denis Merigoux
a4207c9d9e
Last corrections 2022-09-08 14:54:02 +02:00