Commit graph

41 commits

Author SHA1 Message Date
Joshua Warner
51f2cdccf7
Relax argument indentation requirements in closures 2025-01-16 21:27:40 -08:00
Joshua Warner
d43ad92789
Introduce proper type for TypeVar's, mark anything not a lowercase ident as malformed 2025-01-14 19:30:33 -08:00
Sam Mohr
2150ee2219
Remove Task from Roc 2025-01-08 17:00:40 -08:00
Sam Mohr
cbcbfd3265
Remove backpassing 2025-01-01 17:44:56 -08:00
Joshua Warner
7d91b01c5a
Fix where clauses in tuple types with trailing commas 2025-01-01 14:59:11 -05:00
Joshua Warner
9ff1b630a8
Fix accidental NoProgress return in if, to avoid exponential parsing issue 2025-01-01 12:40:54 -05:00
Joshua Warner
37e7caa1aa
Parenthesize closures in unary ops and pre-emptively disallow multi-backpassing in such closures, to avoid formatter trouble later 2025-01-01 12:38:28 -05:00
Joshua Warner
59fe0f06ea
Make sure to use keyword rather than word for parsing keywords 2024-12-28 22:29:45 -05:00
Joshua Warner
9e6c249dca
Disallow any keyword followed by an exclaimation mark 2024-12-28 22:29:45 -05:00
Joshua Warner
0acd59b4d6
Treat crash keyword uniformly 2024-12-28 22:29:42 -05:00
Joshua Warner
941c6c4fe3
Fix exponential behavior in parsing function types in tuples 2024-12-24 11:20:36 -05:00
Joshua Warner
9499dcec4b
Disallow implements even with spaces around it 2024-12-23 14:34:41 -05:00
Joshua Warner
ad1e3369c5
Disallow expect! as an identifier 2024-12-21 20:14:18 -05:00
Joshua Warner
11d8dd1335
Fixup error case 2024-12-15 18:33:54 -08:00
Joshua Warner
6ef87b3b9d
Graccefully handle overflowing unicode literals 2024-12-15 18:33:54 -08:00
Joshua Warner
d3426ebce1
Fix empty SpaceBefore instance 2024-12-13 13:45:11 -08:00
Joshua Warner
78cda703d9
Fixup negative allowance in calls 2024-12-05 18:54:20 -08:00
Joshua Warner
e47d7924d3
Fix parsing crash with dollar escapes 2024-12-05 18:54:15 -08:00
Joshua Warner
b9862b47dc
Several fixes found in fuzzing 2024-12-05 18:54:03 -08:00
Joshua Warner
085c5e2fe7
Fix nasty perf bug in parsing types 2024-12-01 12:39:47 -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
Agus Zubiaga
7a7650c11d
Parse lowercase idents ending in ! 2024-11-07 18:54:14 -03:00
Sam Mohr
7518a2c5ab
Address PR comments, add syntax tests 2024-10-21 03:06:43 -07:00
hrishisd
cb98c45e88
Remove deprecated string interpolation syntax 2024-10-08 16:31:22 -04:00
snobee
6edee521cb
add tests 2024-09-06 19:34:11 -07: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
Agus Zubiaga
760ffaf68f
Report module params parse error 2024-05-09 07:27:58 -03:00
Agus Zubiaga
2a8ecbba28
Do not drop import parse errors 2024-05-07 22:39:43 -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
Agus Zubiaga
42e755677c
Simply import parsing and formatting by using header::KeywordItem 2024-01-20 08:35:50 -03:00
Agus Zubiaga
c56091ee3e
Module Params' proposal import syntax
I previously implemented the syntax in "Proposal: Module and Package Changes" [1]:

```
import [map, map2] from JsonDecode as JD
```

However, we decided [2] to use the one that appears in "Proposal: Module Params" [3]:

```
import JsonDecode as JD exposing [map, map2]
```

The new implementation also now supports comments and newlines between all the tokens.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit
[2] 405410612
[3] https://docs.google.com/document/d/110MwQi7Dpo1Y69ECFXyyvDWzF4OYv1BLojIm08qDTvg/edit
2024-01-20 08:35:50 -03:00
Agus Zubiaga
76d799ea13
Parse and format aliases in import defs 2024-01-20 08:35:50 -03:00
Agus Zubiaga
ebc3aab91f
Allow where to be used as an identifier (except in type vars) 2023-09-30 01:48:10 -03:00
Richard Feldman
0176b9310d
Update snapshot tests 2023-08-10 21:51:01 -04:00
Bryce Miller
cb08225bf0
| -> where 2023-06-05 20:19:00 -04:00
Bryce Miller
91e37293a2
abilities syntax has -> implements 2023-05-24 21:29:38 -04:00
Joshua Warner
0b8e68f70d
Fix approximately a bajillion fmt and parsing bugs
(discovered by fuzzing)

There's more to come, but this seems like a good batch for now.
2023-01-13 18:20:44 -08:00
Joshua Warner
94070e8ba6
Improve parsing of scalar literals
* Unify parsing of string literals and scalar literals, to (e.g.) ensure escapes are handled uniformly. Notably, this makes unicode escapes valid in scalar literals.
* Add a variety of custom error messages about specific failure cases of parsing string/scalar literals. For example, if we're expecting a string (e.g. a package name in the header) and the user tried using single quotes, give a clear message about that.
* Fix formatting of unicode escapes (they previously used {}, now correctly use () to match roc strings)
2023-01-07 15:12:52 -08:00
Joshua Warner
0da50a612d
Be more lenient with required indentation in collections
... and also remove a bunch of now-dead errors that can't be triggered.
2023-01-01 17:49:51 -08:00
Joshua Warner
bfeddc470a
Move syntax tests to a dedicated crate
* test_fmt moves out of fmt crate
* test_parse _mostly_ moves out of parse crate and into `test_snapshots.rs` (some simple tests remain)
* now there's only two fuzz targets, fuzz_expr and fuzz_module, that cover both parsing and formatting
* added a system to auto-add new snapshot entries for new test files
* took some commented-out tests in `test_parse` and converted them to snapshot tests
* moved test_fmt's verification of formatting consistency into test_snapshots
* fixed a huge derp on my part where the fmt fuzzer in #4758 was completely useless (broken by refactoring just prior to submitting the PR)
* fixed a formatting bug found by fuzzing (bound_variable.expr.roc) - that I missed earlier due to ^^^ that derp
* no longer have roc_test_utils as a dependency in fmt - which was causing problems for the wasm build
2022-12-26 22:50:24 -08:00