Commit graph

135 commits

Author SHA1 Message Date
Trevor Settles
bf40247aec
example and docs for fail 2024-03-10 15:06:52 -06:00
Trevor Settles
4e33a6c4b3
fail_when example and docs 2024-03-09 21:25:57 -07:00
Trevor Settles
3770b72530
example for succeed 2024-03-09 19:22:54 -07:00
Trevor Settles
c582ad6767
example for skip_second 2024-03-09 18:46:52 -07:00
Trevor Settles
eed1957180
skip_first example 2024-03-09 18:42:33 -07:00
Trevor Settles
cad29623f9
loc macro example 2024-03-08 22:37:59 -07:00
Trevor Settles
9c67ae15be
example for optional 2024-03-08 22:04:27 -07:00
Trevor Settles
f3666b346b
example for keyword_e 2024-03-05 18:51:28 -07:00
Trevor Settles
997222a1ce
removed imports and example for then 2024-03-04 23:14:48 -07:00
Trevor Settles
62e6e34470
examples for allocated 2024-03-03 21:55:59 -07:00
Trevor Settles
3cb0edf958
added and_then docs 2024-03-03 12:34:56 -07:00
Trevor Settles
3f2d2dd908
added and examples 2024-03-03 11:50:24 -07:00
Trevor Settles
58c654a092
removed erroneus wrapping function 2024-03-03 11:32:18 -07:00
Trevor Settles
b7181af8f3
better formatting for word docs 2024-03-03 11:15:09 -07:00
Trevor Settles
ff19d1b834
pass and fail examples 2024-03-03 11:02:02 -07:00
Agus Zubiaga
11e0202eb9
Parse inline imports and ingested files at the expression level
```
numbers =
    import "numbers.json" as numbersJson : Str
    import json.Decode exposing [decode, list, int]

    numbersJson
    |> decode (list int)
    |> Result.withDefault []
```
2024-01-20 08:35:50 -03:00
Agus Zubiaga
4d6e641864
Parse and format inline ingested file imports 2024-01-20 08:35:50 -03:00
Agus Zubiaga
42e755677c
Simply import parsing and formatting by using header::KeywordItem 2024-01-20 08:35:50 -03:00
Agus Zubiaga
65ce811587
Parse and format import package shorthand
The original proposal [1] suggested dropping the package shorthand,
but we later decided to keep it [2] to improve UX.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit?usp=sharing
[2] 385104011
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
5cd084b73c
Parse and format inline import with exposed names 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
933fde77a0
Parse and format top-level import defs with no alias or exposed members 2024-01-20 08:35:50 -03:00
Folkert
e6a154765c
silence some redundant closure call warnings caused by macros 2023-10-07 19:11:36 +02:00
Anton-4
f0795e6935
minor improvements 2023-09-15 19:51:13 +02:00
Anton-4
954f687666
minor fixes 2023-08-11 16:14:33 +02:00
Bryce Miller
2f5695e59d
use word instead of word10 2023-05-22 22:29:32 -04:00
Bryce Miller
0f289ed712
add word10 fn 2023-05-19 21:13:33 -04:00
Agustin Zubiaga
f94004d137 Parse builders without backtracking from records 2023-05-13 20:05:42 -03:00
Agustin Zubiaga
735721769c Record Builder parsing 2023-05-05 23:26:20 -03:00
Brendan Hansknecht
99547086ee
add very rough framework of how the parse might need to change 2023-04-09 14:03:31 -07:00
Joshua Warner
5a6be05ead
implement mono / lowering for tuples 2023-02-07 18:54:50 -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
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
07ebc81cba
Be more lenient with indentation in record parsing
... and extract a shared helper with collection_trailing_sep_e, thereby resolving some inconsistencies with normal collection parsing.

... and delete some dead code while I'm at it
2023-01-02 18:53:15 -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
Folkert
8305d078a0
add as for list rest patterns 2022-12-30 23:17:29 +01:00
Folkert
e9196f3c0b
parse and format pattern as 2022-12-30 17:50:17 +01:00
Ayaz
dbdf4acdd7
Merge pull request #4758 from joshuawarner32/fuzzing-take-2
Add fuzzing for the formatter and fix bugs
2022-12-22 06:35:34 -07:00
Richard Feldman
09764be7c3
Go back to PackageName 2022-12-18 10:11:19 -05:00
Joshua Warner
a046428ce6
Add fuzzing for the formatter and fix bugs
This commit adds fuzzing for the (expr) formatter, with the same invariants that we use for fmt tests:
  * We start with text, which we parse
  * We format the AST, which must succeed
  * We parse back the AST and make sure it's identical igoring whitespace+comments
  * We format the new AST and assert it's equal to the first formatted version ("idempotency")

Interestingly, while a lot of bugs this found were in the formatter, it also found some parsing bugs.

It then fixes a bunch of bugs that fell out:
* Some small oversights in RemoveSpaces
* Make sure `_a` doesn't parse as an inferred type (`_`) followed by an identifier (parsing bug!)
* Call `extract_spaces` on a parsed expr before matching on it, lest it be Expr::SpaceBefore - when parsing aliases
* A few cases where the formatter generated invalid/different code
* Numerous formatting bugs that caused the formatting to not be idempotent

The last point there is worth talking further about. There were several cases where the old code was trying to enforce strong
opinions about how to insert newlines in function types and defs. In both of those cases, it looked like the goals of
(1) idempotency, (2) giving the user some say in the output, and (3) these strong opinions - were often in conflict.

For these cases, I erred on the side of following the user's existing choices about where to put newlines.

We can go back and re-add this strong opinionation later - but this seemed the right approach for now.
2022-12-17 09:52:09 -08:00
Richard Feldman
d022c19f5c
Merge remote-tracking branch 'origin/main' into packages 2022-12-13 06:04:43 -05:00
Richard Feldman
3d1cdf1fd4
Merge pull request #4737 from roc-lang/to
Use app module's `to` to determine platform
2022-12-13 06:04:25 -05:00
Richard Feldman
ec9cf4efe2
Merge branch 'to' into packages 2022-12-12 01:15:34 -05:00
Richard Feldman
8a9e152a5b
Rename PackageName to PackagePath 2022-12-12 00:41:55 -05:00
Joshua Warner
5f29402297
Give parser fuzzing some TLC
* The header + expr fuzzers can both be run again (header fuzzer had regressed).
* I ran the expr fuzzer for ~60 seconds with no additional panics uncovered
* "tab_crash" hit supposedly unreachable code in blankspace.rs - and I went to the liberty of dramatically simplifying all that code, rather than just trying to fix the bug
* Other failures were straight-forward error cases that should have been handled (and passed up the chain) instead of panicking
2022-12-11 08:39:52 -08:00
Richard Feldman
da595a86b0
Parse package module header 2022-12-04 06:26:44 -05:00
Joshua Warner
2b91af02df
Introduce record! combinator
... and refactor header parser to fully use combinators, in support of future combinator-based superpowers
2022-11-28 20:25:55 -08:00
Richard Feldman
c1a75a57f1
Merge pull request #4592 from roc-lang/collections_refactor
Refactor collection_trailing_sep_e
2022-11-28 11:14:30 -05:00
Joshua Warner
451b2c0ded
Refactor collections 2022-11-26 09:55:54 -08:00