Commit Graph

208 Commits

Author SHA1 Message Date
Luke Boswell
2d0bed5634
formatting 2023-03-12 17:11:35 +11:00
Luke Boswell
1e26769313
add support for @,_,* tokens 2023-03-12 17:01:05 +11:00
Luke Boswell
2bed7da218
improve token categories and color scheme 2023-03-10 11:38:42 +11:00
Brendan Hansknecht
f42f61e271
run a toml formatter and then clean it up a bit 2023-03-06 19:47:57 -08:00
Brendan Hansknecht
4a89bee0a5
centralize package versions except for vendor and excluded 2023-03-06 19:29:09 -08:00
Brendan Hansknecht
5485c8a5b0
update to using workspace package spec 2023-03-06 16:36:18 -08:00
Brendan Hansknecht
21af20597e
remove unused dependencies 2023-03-06 12:09:00 -08:00
Joshua Warner
2dfe373311
Produce combined tokens directly and add a few operators
This (I believe) brings us in line with the complete set of operators supported in Roc.
2023-03-04 21:42:33 -08:00
Anton-4
cf913814cb
fmt 2023-03-01 19:57:39 +01:00
Luke Boswell
f51aef42bb
add support for slashes 2023-03-01 19:06:15 +11:00
Luke Boswell
c9ffedb483
add ? token 2023-03-01 18:38:16 +11:00
Luke Boswell
5f8629f64e
bug fix for highlighting 2023-03-01 18:00:30 +11:00
Luke Boswell
1590b30b19
Add a lexing-based 'highlight' mode to the parser
basic syntax highlighting

added more syntax highlighting coverage

add example of a markdown table with styling

move FIXED_TOKEN logic into highlight

refactor highlight, add support for backpassing

escape html from source code

fix bug with <pre> tag ordering

refactor out html from roc_parse

remove test, put highlight functionality into separate file

fix typo
2023-02-28 17:03:49 +11:00
Joshua Warner
b5f284cd78
Fix several fmt+parse bugs found by fuzzing 2023-02-19 12:37:33 -08:00
Ayaz
9340a67e87
Merge pull request #4993 from joshuawarner32/tuple-gen-tuple-backend-experiment
Implement mono / code generation for tuples
2023-02-08 10:42:51 -05:00
Joshua Warner
3fee0d3e8f
Fix a bunch of bugs in parsing/formatting found by fuzzing 2023-02-07 20:25:56 -08:00
Joshua Warner
5a6be05ead
implement mono / lowering for tuples 2023-02-07 18:54:50 -08:00
Joshua Warner
31a4eb2bfd
Fix parsing of tuple accessors after an identifier - e.g. myIdent.2 2023-01-30 21:12:01 -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
Anton-4
bbf35af8fa
Merge branch 'main' into rust1_65
Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
2023-01-17 18:14:30 +01:00
Anton-4
a97c53d7ca
1.65 changes and clippy fixes 2023-01-17 18:09:16 +01:00
Joshua Warner
3b51d7cd13
Fix multi-backpassing in top-level defs
Fixes #4821
2023-01-15 10:39:21 -08:00
Ayaz
545e6bc989
Merge pull request #4884 from joshuawarner32/fmt-fuzzing-fixes
Fix approximately a bajillion fmt and parsing bugs
2023-01-14 19:45:30 -06: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
Ayaz
fdb4fe66ee
Merge pull request #4820 from joshuawarner32/remove-parser-generator
Remove accidentally committed parser generator
2023-01-11 23:14:52 -06: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
aff70bb6bd
refactor PatternAs 2022-12-30 18:22:10 +01:00
Folkert
e9196f3c0b
parse and format pattern as 2022-12-30 17:50:17 +01:00
Joshua Warner
a15e6c5c37
Remove accidentally committed parser generator 2022-12-27 16:55:54 -08:00
Anton-4
c3b0295a92
Merge pull request #4813 from joshuawarner32/test_syntax
Move syntax tests to a dedicated crate
2022-12-27 13:15:01 +01:00
Anton-4
f0ea60df51
use latest cli platform, added wasm repl build test 2022-12-27 11:31:15 +01: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
Richard Feldman
d8d517d6f9
Support generating docs for packages too 2022-12-24 22:32:14 -05:00
Richard Feldman
e549456668
Store exposed module IDs in file loading state 2022-12-24 22:32:13 -05: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
3e5b62db1a
Move exposes into HeaderType 2022-12-13 06:59:25 -05:00
Richard Feldman
7512a964f7
Add HeaderType::Package 2022-12-13 06:44:02 -05: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
4de0c831bd
Merge pull request #4716 from roc-lang/fuzzing-take-1
Give parser fuzzing some TLC
2022-12-12 18:56:11 -05:00
Folkert de Vries
c5df39daf4
Merge pull request #4735 from nfreesto/fmt-fix
Fix for #4585
2022-12-12 19:34:21 +01: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
Nathan Freestone
04c9454c20
changed expected output for tests to reflect new behavior 2022-12-11 18:39:14 -07:00
Joshua Warner
e83cd8f191
Re-improve perf of skipping spaces and comments
On my M1 mac this shows as ~25% faster at parsing Num.roc than the old implementation, probably because nobody wrote any NEON code.

Even on my x86_64 linux box (Ryzen 2700x), this shows as 10% faster than the current SSE implementation (running with RUSTFLAGS="-C target-cpu=native").
2022-12-11 08:43:22 -08:00