Commit graph

73 commits

Author SHA1 Message Date
Anthony Bullard
eb9d1bcf09
Format apply funcs with try suffix correctly 2025-01-28 21:00:30 -06:00
Sam Mohr
631e59ce06
Upgrade hosted header in the style module header 2025-01-26 15:07:57 -08:00
Joshua Warner
20d092ea48
Remove indented-else syntax from the formatter
This is step 1 in removing the syntax all together. The formatter will now seemlessly migrate everyone to the usual if/then/else syntax. After everyone has had a chance to upgrade, we can then remove this from the parser (in a future PR).
2025-01-20 19:18:37 -08:00
Sam Mohr
1a9668e83a
Add tests for desugaring and formatting 2025-01-17 18:55:58 -08:00
Anthony Bullard
1b43ffa579
Format all lambdas to new syntax 2025-01-16 08:03:44 -06:00
Anthony Bullard
8e1e1520e3
New Lambda Syntax with |...|
This adds parser support for the new lambda syntax.  It does not remove
the existing syntax, nor will the new syntax be retained in formatting.
That will be done in a separate PR to keep the two respective PRs
relatively small and easy to review.
2025-01-15 05:58:16 -06:00
Anthony Bullard
4e66910ef8
Add a few tests 2025-01-15 05:56:39 -06:00
Sam Mohr
eb1b5ffa26
Move to new interpolation syntax 2025-01-10 10:29:20 -08:00
Anthony Bullard
898b3f55e5
Move PNC apply to separate Expr/Pattern variant 2025-01-08 14:47:49 -06:00
Sam Mohr
8e5d875604
Merge branch 'main' into auto-snake-case 2025-01-08 01:51:12 -08:00
Luke Boswell
68f4aabbce
remove example formatting test from test_syntax 2025-01-08 16:36:34 +11:00
Sam Mohr
cd0e2a4474
Merge branch 'main' into auto-snake-case 2025-01-05 16:50:24 -08:00
Sam Mohr
b56fbd38e1
Progress on updating entire compiler for snake_case 2025-01-05 03:48:03 -08:00
Anthony Bullard
a24fe430b4
Support '??' syntax for optional record fields 2025-01-04 14:26:20 -06:00
Anthony Bullard
89b7900d7a
Migrate type vars to snake case (Redo) 2025-01-03 19:52:21 -06:00
Anthony Bullard
3b0db07fa1
PNC for Patterns, stabilize formatting 2025-01-02 17:57:15 -06:00
Anthony Bullard
389cc940e0
Git rid of MigrationFlags constructor 2025-01-02 16:49:08 -06:00
Anthony Bullard
af39ce57fb
Parens and Commas application syntax 2025-01-02 16:49:08 -06:00
Sam Mohr
cbcbfd3265
Remove backpassing 2025-01-01 17:44:56 -08:00
Joshua Warner
b4fa7294c7
Extend test_syntax to check that canonicalization doesn't panic on the input
Importantly, this would have caught the issue discovered in #7279, prior to that landing on main.
2024-12-06 17:13:10 -08:00
Joshua Warner
84b3969648
Adjust parens around patterns in annotations 2024-12-05 18:54:08 -08:00
Joshua Warner
120e9be550
Move MigrationFlags from an argument on format* to a field on Buf
That has a few advantages:

* We avoid a bunch of extra parameter-passing "noise", since the vast majority of formatting code doesn't need to care about this setting beyond just passing it to nested format calls.
* It aligns really well with the "global" nature of this setting, and makes it impossible to have bugs where e.g. one callsite forgets to pass the correct value to it's children - which would lead to parts of the tree not being migrated. If this is truly a global setting on Buf, that simply can't happen.
2024-12-04 17:57:31 -08:00
Anthony Bullard
a2083cec30
Parsing support for snake_case identifiers
In this initial commit, I have done the following:

- Added unit tests to roc_parse's ident.rs file to cover at least the
  simplest Ident enum cases (Tag, OpaqueRef, and simple Access)
- Added '_' as a valid "rest" character in both uppercase and lowercase
  identifier parts
- Updated the test_syntax snapshots appropriately

There is still a lot left to do here. Such as:

- Do we want to allow multiple '_'s to parse successfully?
- Handle qualified access
- Handle accessor functions
- Handle record update functions
- Remove the UnderscoreInMiddle case from BadIdent
- Write unit tests for Malformed Idents

I am not a "Rustacean" by any means, but have been through the Book in
years past.  Any feedback on the way I wrote the tests or any other part
of the implementation would be very appreciated.
2024-12-03 20:50:47 -06:00
Joshua Warner
f7a5f06e5b
Fix a bunch of bugs found in fuzzing 2024-12-01 12:40:19 -08:00
Anton-4
74d137cad4
Revert "Merge pull request #7267 from joshuawarner32/fuzzing-bugs-2"
This reverts commit 364249a29d, reversing
changes made to 0e550a7f68.
2024-11-30 18:43:16 +01:00
Joshua Warner
ed62bcc15a
Fix a bunch of parser/formatter bugs found in fuzzing
Notably:
* Unified how parens are formatted between (1) when we have a ParensAround, and (2) when we've decided an Apply needs to have parens
* Made unary minus require the be indented to the same level as any other expression continuation. (it used to accidentally have rules meant for binary operators applied)
* Don't apply extra indent to the backpassing continuation in the case that the call does itself require indentation
* Make `try@foo` correctly parse as `try @foo`, so that formatting doesn't change the tree when it adds that space
* Detect more cases where we need to outdent trailing e.g. {} blocks in applies
* Approximately a bagillion other things, 90% of which I added tests for, and none of which affected the formatting of examples or builtins
2024-11-29 16:25:59 -08:00
Sam Mohr
de124ecc3e
Finish adding tests 2024-11-02 21:58:25 -07:00
Sam Mohr
2da08be8ef
Remove old record builder syntax 2024-09-21 04:44:44 -07:00
snobee
6edee521cb
add tests 2024-09-06 19:34:11 -07:00
Sam Mohr
12df3a04de
Merge attempt 2024-08-19 23:34:05 -07:00
Sam Mohr
7e72541a79 Merge branch 'main' into builtin-task 2024-08-12 23:12:38 -07:00
Joshua Warner
d25c048d48
Move Full from fmt to parse and reorganize confusingly-named Module ast type 2024-08-07 23:01:49 -07:00
Sam Mohr
8288af3156
Merge branch 'main' into builtin-task 2024-07-31 13:36:32 -07:00
Aidan
2529fa0721 get rid of extra newlines 2024-07-29 11:10:16 -04:00
Aidan
125990855f Merge branch 'main' into store-all-space-between-annotation-body 2024-07-29 09:46:05 -04:00
Luke Boswell
eca453d07f
Merge remote-tracking branch 'remote/main' into builtin-task 2024-07-29 16:05:51 +10:00
Joshua Warner
ecb8b12167
Add back working tests 2024-07-27 14:49:56 -07:00
Aidan
2738cd717d cargo fmt 2024-07-27 17:37:28 -04:00
Aidan
4e4d9b0d4c add tests 2024-07-27 17:18:58 -04:00
Aidan
7fe052322c update test, fix logic 2024-07-27 16:55:13 -04:00
Joshua Warner
4f32f43048
Implement block / indent based parsing
... and enforce that defs can only occur in blocks (or, inside parenthesized expressions)
2024-07-27 13:34:16 -07:00
Aidan
db1c230f1f add test 2024-07-27 12:50:48 -04:00
Luke Boswell
b489c44b19
Merge remote-tracking branch 'remote/main' into builtin-task 2024-07-19 19:51:50 +10:00
Sam Mohr
618b713ecd
Merge branch 'main' into new-builder-syntax 2024-07-07 18:33:36 -07:00
Sam Mohr
f415017c90
Implement new builder syntax alongside old one 2024-07-07 03:28:59 -07:00
JRI98
25084b18ec
Fix handling of spaces after for as 2024-07-05 09:40:56 +01:00
Sam Mohr
700c7ae9aa
Add Task as a built-in module/type 2024-06-25 00:03:56 -07:00
Evan Relf
2a71dccf5e Add tests 2024-06-19 15:19:25 -07:00
Agus Zubiaga
e3b600c282
New package header syntax
Implements the new package header syntax as discussed in Zulip [1].

package [Csv] {
    parser: "../parser/main.roc"
}

Old headers still parse and are automatically upgraded to the new
syntax by the formatter.

[1] 418444862
2024-05-01 10:49:03 -03:00
Agus Zubiaga
8dedd9f03c
New app header syntax
Implements the new app header syntax as discussed in Zulip [1].

    app [main] {
	cli: platform "../platform/main.roc",
	json: "../json/main.roc"
    }

Old headers still parse and are automatically upgraded to the new
syntax by the formatter.

[1] 418444862
2024-05-01 10:49:01 -03:00