Commit Graph

43 Commits

Author SHA1 Message Date
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
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
98fc97a241 Rewriting message calls to use the new intf 2024-04-10 19:26:23 +02: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
8df49dcea2 More tests and some fixes 2023-11-30 23:49:19 +01: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
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
Louis Gesbert
69be2f6ed8 Fix literate output of dates 2023-03-21 16:59:34 +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
Louis Gesbert
3f487a16ed WIP: handle toplevel definitions at the parser level 2023-02-13 10:51:42 +01:00
Louis Gesbert
e678d0770f Rename a few tokens
In particular `CONSTRUCTOR` is no longer valid for paths & modules, so let's
switch to the more usual LIDENT / UIDENT for lower- or upper- case idents.

cd compiler/surface
sed -i 's/VERTICAL/BAR/g' *
sed -i 's/BRACKET/BRACE/g' *
sed -i 's/SQUARE/BRACKET/g' *
sed -i 's/IDENT/LIDENT/g' *
sed -i 's/CONSTRUCTOR/UIDENT/g' *
2022-12-19 15:17:17 +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
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
9b939d07a4 New syntax for collection operations 2022-12-13 12:30:40 +01:00
Louis Gesbert
fea01cfe4c Add overloaded operators for the common operations
This uses the same disambiguation mechanism put in place for
structures, calling the typer on individual rules on the desugared AST
to propagate types, in order to resolve ambiguous operators like `+`
to their strongly typed counterparts (`+!`, `+.`, `+$`, `+@`, `+$`) in
the translation to scopelang.

The patch includes some normalisation of the definition of all the
operators, and classifies them based on their typing policy instead of
their arity. It also adds a little more flexibility:
- a couple new operators, like `-` on date and duration
- optional type annotation on some aggregation constructions

The `Shared_ast` lib is also lightly restructured, with the `Expr`
module split into `Type`, `Operator` and `Expr`.
2022-12-13 11:55:24 +01:00
Louis Gesbert
660e5775de Rename utils to catala_utils 2022-11-28 16:38:09 +01:00
Denis Merigoux
755b1212a2
Remove division durations 2022-08-19 15:21:29 +02:00
Louis Gesbert
f35f18b295 Add local 'let in' bindings 2022-08-09 12:17:31 +02:00
Louis Gesbert
6d41818e0a Change syntax for set membership predicate
Before: `ELEMENT in SET`; now: `SET contains ELEMENT`

Using the `in` keyword was causing conflicts and blocking #203.
Current proposal has `contient` for the French syntax, and is untranslated (`contains`) for Polish.
2022-07-27 14:34:58 +02:00
Denis Merigoux
100c84a741
Allow negative literals 2022-07-21 14:14:22 +02:00
Denis Merigoux
dcf80f4bec
Adding first_day_of_month and last_day_of_month 2022-07-21 14:14:04 +02:00
Denis Merigoux
be373f0ff5
Added primitives money_to_decimal and decimal_to_money [skip ci] 2022-07-19 11:53:09 +02:00
kescher
db9eec3b9f add support for duration multiplication
Signed-off-by: Jonathan Protzenko <protz@microsoft.com>
2022-05-31 11:17:38 -07:00
Denis Merigoux
a52cc0d881
Move fix to lexer as suggested by @altgr 2022-05-06 10:29:39 +02:00
Denis Merigoux
78e8275d5e
Adds a decimal rounding operator 2022-04-29 21:18:15 +02:00
Denis Merigoux
1c86c8298b
Fix decimal parsing 2022-04-22 14:26:28 +02:00
Denis Merigoux
cdac6de9fe
Implement the round money builtin 2022-03-17 12:30:14 +01:00
Denis Merigoux
eb7f00f56d
Syntax: parser and highlighting 2022-02-28 14:33:07 +01:00
Denis Merigoux
11d4a34783
Better printing, tests, fix parser ommission 2022-02-04 15:10:47 +01:00
Denis Merigoux
05a0bfc9b7
Added parsing support for #112, missing all later compilation steps 2022-01-27 18:03:47 +01:00
Emile Rolley
397b0e1d7c fix(build/doc): remove warnings due to .ml* files 2022-01-02 14:53:51 +01:00
Denis Merigoux
a06cbe8614
Fix literate programming problems 2021-11-26 18:07:46 +01:00
Emile Rolley
9aaa614410 refactor(parser): add the new catala-metadata markup 2021-10-01 10:01:25 +02:00
Louis Gesbert
dc026d0a7f I was still unhappy with the remaining duplication
that and the double-matching with different kinds of regexps; it should be more
robust now.
2021-08-20 14:23:10 +02:00
Louis Gesbert
dfb358993c Small fix 2021-08-19 20:41:34 +02:00
Louis Gesbert
98aed4187a Further factorise decimals parsing 2021-08-19 20:32:23 +02:00
Louis Gesbert
e431e194de Factorise lexer translations 2021-08-19 18:26:06 +02:00