Commit graph

253 commits

Author SHA1 Message Date
Joshua Warner
dfcb7a0c3b
Ensure formatted multiline patterns can be parsed 2024-12-05 18:54:21 -08:00
Joshua Warner
78cda703d9
Fixup negative allowance in calls 2024-12-05 18:54:20 -08:00
Joshua Warner
1be2075e7f
Make sure ext's can't slurp surrounding apply args 2024-12-05 18:54:19 -08:00
Joshua Warner
fc74b67d86
Flesh out expr_lift_spaces, in particular handling DbgStmt properly 2024-12-05 18:54:19 -08:00
Joshua Warner
5c387857ff
Indented seq parsing for imports 2024-12-05 18:54:18 -08:00
Joshua Warner
2163b28390
Fix formatting of newlines in parens in a function type 2024-12-05 18:54:18 -08:00
Joshua Warner
cae47cf2a6
Fix expr_lift_spaces of Closure 2024-12-05 18:54:17 -08:00
Joshua Warner
19f8cc532a
Disallow conditionals after neg/not 2024-12-05 18:54:17 -08:00
Joshua Warner
7eb9909ac5
Make parsing of conditionals consistent between stmts/exprs 2024-12-05 18:54:16 -08:00
Joshua Warner
e47d7924d3
Fix parsing crash with dollar escapes 2024-12-05 18:54:15 -08:00
Joshua Warner
89a64fed74
Don't do empty record destructure elision when the body is itself Defs 2024-12-05 18:54:15 -08:00
Joshua Warner
cabe67f88d
Only allow indented else if there's a newline after the else 2024-12-05 18:54:14 -08:00
Joshua Warner
48c941d542
Add lifting for ext values in types 2024-12-05 18:54:14 -08:00
Joshua Warner
64164eb1f4
Make sure patterns continue to parse as such 2024-12-05 18:54:13 -08:00
Joshua Warner
ea1ecb9e68
Fix lifting of backpassing 2024-12-05 18:54:12 -08:00
Joshua Warner
2098ccd137
Fix multiline pattern in body, which may only apply to multiline strings 2024-12-05 18:54:12 -08:00
Joshua Warner
ab4c96bc81
Fix indent call in when fmt 2024-12-05 18:54:11 -08:00
Joshua Warner
fa4d3e79ec
Fix ability with no newline after it 2024-12-05 18:54:11 -08:00
Joshua Warner
b06afa7bb9
Fix purity removal 2024-12-05 18:54:10 -08:00
Joshua Warner
8c25c9aaf7
Fix newline after dbg formatting 2024-12-05 18:54:10 -08:00
Joshua Warner
4a0dce714b
Unify if/when condition formatting 2024-12-05 18:54:09 -08:00
Joshua Warner
cfec120b13
Fix indent calls in optional fields 2024-12-05 18:54:08 -08:00
Joshua Warner
edcdd99f59
Record updates 2024-12-05 18:54:07 -08:00
Joshua Warner
b9862b47dc
Several fixes found in fuzzing 2024-12-05 18:54:03 -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
Joshua Warner
5cd38c969f
Fix a couple minor parsing bugs 2024-12-01 12:40:17 -08:00
Joshua Warner
d4301e86a3
Improve parsing of negative + not'd exprs 2024-12-01 12:40:16 -08:00
Joshua Warner
61d885039d
Improve normalization to handle cases found in fuzzing 2024-12-01 12:40:14 -08:00
Joshua Warner
912db1b76b
Fix round-trip parse->fmt->parse for dbg stmts with more than one arg 2024-12-01 12:40:13 -08:00
Joshua Warner
cfd83ffcdf
Add some currently-passing tests 2024-12-01 12:40:08 -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
Joshua Warner
9ead801536
Remove expect-fx syntax and handling
This was never fully hooked up in platforms, and the plan is to replace the need for this with doing purity-inference on normal `expect` statements.

On the other hand, fuzzing is finding some bugs caused by having a hyphenated keyword, so this is a great time to go ahead and remove it!
2024-11-17 20:25:37 -08:00
Joshua Warner
550113df67
Fix some bugs found via fuzzing
* Keywords need to still be recognized if they're followed by ',' as well as a bunch of other operator characters. Notably missing from this list is '-', since that would mess up expect-fx currently.
* Smattering of niche cases of formatting bugs (either non-idempotency, leading to different code, or leading to unparsable code)
* One missing indent call in fmt_collection leading to a panic
2024-11-15 21:33:44 -08:00
Agus Zubiaga
7a7650c11d
Parse lowercase idents ending in ! 2024-11-07 18:54:14 -03:00
Agus Zubiaga
2cce5ad023
Allow unsuffixed statements in parser
Moves the "STATEMENT AFTER EXPRESSION" error from the parser to canonicalization.
We'll later use this to allow this case in effectful functions.
2024-11-07 18:54:14 -03:00
Agus Zubiaga
ef4eeb5c1a
Parse effectful arrow in function annotations 2024-11-07 18:54:11 -03:00
Sam Mohr
de124ecc3e
Finish adding tests 2024-11-02 21:58:25 -07: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
Elias Mulhall
19931ecd43
Support passing values into dbg with the pipe operator
In order to desugar `dbg` in a pipeline we need to allow a bare `dbg`
node in desugaring and only report it as an error if the bare node
survives to the next step of canonicalization. This means we move the
error code out of `desugar_expr` and into `canonicalize_expr`. This is
much simpler to do now that these functions use the same `env` struct,
since previously we would have had to pass down extra args to
`canonicalize_expr`. Sharing the `env` struct means that we also don't
have to worry about calculating `line_info` more than once.
2024-09-05 20:13:54 -04:00
Agus Zubiaga
2469a3aa2d
Merge pull request #7050 from roc-lang/arg-patterns-as 2024-09-02 14:02:17 -03:00
Agus Zubiaga
2486ce0e48
fmt: Add parens around as patterns in arguments 2024-09-02 11:54:34 -03:00
Elias Mulhall
335265e15c Parse dbg in expression position
Add dbg parsing logic everywhere we parse normal expressions. Add
special case to statement parsing to handle a series of statements
ending in a `dbg` in expression position.

Rename existing `dbg_help` function to `dbg_stmt_help`, similarly rename
syntax snapshot test files to specify which ones are for dbg statements.
2024-08-28 11:53:44 -04:00
Sam Mohr
b1a972ab21
Implement &foo record updater syntax sugar 2024-08-16 01:41:59 -07:00
Sam Mohr
3bc5c1dc12
Combine ! and ? into single TrySuffix AST node 2024-08-14 22:14:08 -07:00
Sam Mohr
00bc699642
Add syntax tests for record builder 2024-08-06 22:49:35 -07:00