Commit graph

41 commits

Author SHA1 Message Date
Joshua Warner
109cb93b20
Implement a migration to new braces syntax and add migrate tests 2025-02-16 20:37:28 -08:00
Sam Mohr
fce14d31b0
Move desugaring to new roc_can_solo crate 2025-01-19 07:16:43 -08:00
Joshua Warner
408379f8d3
Canonicalize the pattern in annotations 2025-01-11 20:24:30 -08:00
Sam Mohr
2150ee2219
Remove Task from Roc 2025-01-08 17:00:40 -08:00
Anthony Bullard
898b3f55e5
Move PNC apply to separate Expr/Pattern variant 2025-01-08 14:47:49 -06:00
Joshua Warner
9fcefb3fd4
Remove panic to appease the panic tracker for now 2025-01-05 16:49:08 -08:00
Joshua Warner
090473434d
Move backtracking for implements to specific spaces case that it's actually needed for, to avoid excess parsing work in extreme cases 2025-01-05 15:10:13 -08:00
Joshua Warner
b7ab25ee2e
Move minimize logging to a new dump_syntax target 2025-01-05 15:10:12 -08:00
Anthony Bullard
89b7900d7a
Migrate type vars to snake case (Redo) 2025-01-03 19:52:21 -06:00
Anthony Bullard
8c77a54b4f
Address review feedback 2025-01-02 17:59:09 -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
Joshua Warner
d8d0b6ebb1
Disallow simplifying empty assignment of dbg 2024-12-28 22:29:46 -05:00
Joshua Warner
a0f828fa57
Don't minimize malformed parses by default 2024-12-21 20:14:19 -05:00
Joshua Warner
511572f7a5
Clippy 2024-12-16 19:08:48 -08:00
Joshua Warner
05ff2efec9
Improve minimize configurability 2024-12-16 18:23:40 -08:00
Joshua Warner
4e3df6bde2
Fix normalization of strings with overflowing unicode 2024-12-15 18:33:56 -08:00
Joshua Warner
1b4f5bbb52
Move indent call to correct spot 2024-12-15 18:33:54 -08:00
Joshua Warner
a83f44188b
Exit with error in minimize tool if there was no problem to minimize 2024-12-15 18:33:53 -08:00
Joshua Warner
4fd18afce7
Make minimization work properly in the presence of unicode chars 2024-12-15 18:33:51 -08:00
Joshua Warner
6b636d9539
Set up module ids properly 2024-12-09 21:24:10 -08:00
Joshua Warner
519bf534b2
Remove commented import 2024-12-07 09:11:52 -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
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
Joshua Warner
2d9aa00771
Rename RemoveSpaces->Normalize 2024-08-12 23:05:55 -07:00
Joshua Warner
0abea91796
Rename Full -> FullAst 2024-08-10 16:06:01 -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
Joshua Warner
df915b936d
Feedback: add doc comments, verbiage changes, capitalize Roc, remove a resolved TODO 2024-07-28 14:45:32 -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
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
7ebfc6d06d
Support both inline and header imports
Load will now convert header imports to inline import defs, so that
we can support both temporarily.
2024-04-20 19:04:09 -03:00
Folkert
ef39bad7c6
auto clippy fixes 2023-07-10 18:27:08 +02:00
Joshua Warner
b5f284cd78
Fix several fmt+parse bugs found by fuzzing 2023-02-19 12:37:33 -08:00
Joshua Warner
a1cd114198
Add a Malformed trait, and assert that 'passing' tests don't produce a malformed result 2023-01-25 21:01:05 -08: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
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