Commit Graph

62 Commits

Author SHA1 Message Date
Chad Stearns
62a004c103 Case is to when is 2019-12-23 17:17:04 -05:00
Chad Stearns
9a5b6a03b4 case when to case is 2019-12-23 17:08:53 -05:00
Chad Stearns
141ad1757b Added test for case with many lines 2019-12-21 13:48:44 -05:00
Chad Stearns
68236aa10b Combine format_newlines_after and format_newlines_before into just format_newlines 2019-12-21 13:32:14 -05:00
Chad Stearns
48a9d898fc Handle excessive newlines below then and else cases 2019-12-21 13:28:34 -05:00
Chad Stearns
858764ac27 Format changes 2019-12-21 02:11:14 -05:00
Chad Stearns
d6186f38ed cargo fmt and clippy 2019-12-20 16:16:45 -05:00
Chad Stearns
32a6afb817 Multi-line if statement 2019-12-20 16:04:09 -05:00
Richard Feldman
d0fa8bf857 Use commas between function arguments 2019-12-18 21:50:45 -05:00
Richard Feldman
3e64447c08 Revise a comment 2019-12-16 21:30:24 -05:00
Chad Stearns
faee0a657d Format code 2019-12-16 13:35:30 -05:00
Chad Stearns
01a283c121 Complicated multiline pattern code with comment 2019-12-16 13:33:13 -05:00
Chad Stearns
5a383b81b8 Commented out failing test 2019-12-16 13:29:09 -05:00
Chad Stearns
d6a3f2cfe9 Removed denest and stopped manually newlining 2019-12-16 13:21:25 -05:00
Chad Stearns
1c64c8088f Handle and format multiline patterns 2019-12-16 12:51:13 -05:00
Chad Stearns
7714639a45 Added test for when lamda arrow is on new line 2019-12-14 22:24:31 -05:00
Chad Stearns
e0ca4ec355 Ran formatter 2019-12-09 06:41:42 -05:00
Chad Stearns
3c8d678c18 New commented out test that is currently breaking under parser errors 2019-12-08 21:51:44 -05:00
Chad Stearns
6e91339700 Format code and tests for newline before return 2019-12-08 21:35:51 -05:00
Chad Stearns
2b58604719 Deleted commented out failing tests, and ran cargo fmt 2019-12-07 00:34:56 -05:00
Chad Stearns
c8acb705f8 Added failing test, removed comment 2019-12-04 22:48:28 -05:00
Chad Stearns
5bc8f24d7f Clarified example 2019-12-04 22:44:59 -05:00
Chad Stearns
7a2fd182df Cohere naming with rest of modul 2019-12-04 22:38:57 -05:00
Chad Stearns
ff6e08daf6 Clarify and comment test. 2019-12-04 22:36:28 -05:00
Chad Stearns
edd8877865 Format tests for comment position and new lines 2019-12-04 22:33:02 -05:00
Richard Feldman
ef7dd313ed Decouple parsing module headers from defs 2019-11-26 20:55:46 -05:00
Richard Feldman
67cceec8ad Format imports 2019-11-25 21:08:20 -05:00
Richard Feldman
4566d15526 Format exposes 2019-11-25 20:52:54 -05:00
Richard Feldman
4926bfbc3a Reorganize fmt and module 2019-11-25 20:42:44 -05:00
Folkert de Vries
4ed1c98881
Merge pull request #9 from rtfeldman/record-patterns
Add record patterns
2019-11-21 13:10:13 +01:00
Richard Feldman
5504b52039 Use assert_formats_same 2019-11-20 18:14:33 -05:00
Richard Feldman
3bc974ab06 Merge branch 'trunk' into format-case 2019-11-20 18:00:07 -05:00
Richard Feldman
c3ecac5abf Reproduce parsing bug 2019-11-20 17:52:50 -05:00
Folkert
d3c14d16d1 parse all records as patterns
This makes the following parse

    # assuming
    Opaque : Opaque Int

    { x: (Opaque y) } = foo

In most cases a pattern of this kind will not be exhaustive, but it
should be syntactically valid.

Couple of things

- conversion of the value (in `key: value`) requires converting from
expr into a pattern, which returns a `Result` which now propagates. A
comment notes though that the cases for which it gives Err should not
parse. so, is the Result useful here?

- AssignedField constructors have a field for spaces, but also a
SpacesAfter constructor. Are they different? it seems like the spaces
field could be removed in favor of using SpacesAfter.
2019-11-20 15:03:58 +01:00
Folkert de Vries
af86b23ab5 Use the RecordField in conversion from assignedField 2019-11-20 15:03:58 +01:00
Folkert de Vries
b44e5e7d94 add RecordField pattern
this will allow pattern matches like

    case foo of
        { x : Just 4 } -> ...
        _ -> ...
2019-11-20 15:03:58 +01:00
Folkert de Vries
3d584a53b0 Use the RecordField in conversion from assignedField 2019-11-20 14:51:06 +01:00
Folkert de Vries
97e8600cdf add RecordField pattern
this will allow pattern matches like

    case foo of
        { x : Just 4 } -> ...
        _ -> ...
2019-11-20 14:51:06 +01:00
Folkert
2af14921a7 add test for nested case 2019-11-20 14:44:32 +01:00
Folkert
53c7fdf52c Implement formatting for case expressions
I hope we can find some better abstractions for this, as it is quite
messy. But this seems to handle comments correctly so far.
2019-11-20 14:37:44 +01:00
Folkert de Vries
8ce7a8e6ed partial formatting of case & comments/newlines 2019-11-20 14:37:44 +01:00
Richard Feldman
76b815ab77 Use $crate in loc macro instead of outside imports 2019-11-20 07:10:31 -05:00
Richard Feldman
cc74c37045 Use loc! macro instead of loc() 2019-11-20 07:10:31 -05:00
Folkert
c39e060ddc Parse BlockString
a couple of open questions:

- shouldn't patterns (for formatting) make the distinction between block
and line?
- can the `arena.alloc` be removed? the Vec is already allocated by bumpalo
- for error reporting, is it better to distinguish block and line?
2019-11-15 18:08:01 +01:00
Richard Feldman
67d512f5fb Remove block comments 2019-11-15 02:01:40 +00:00
Folkert
1e0634ea20 add record newline formatting test 2019-11-14 13:49:40 +01:00
Richard Feldman
f2f3919992 Update test_format to expected record output 2019-11-14 00:12:44 +01:00
Folkert
4fe125f405 Add formatting for records
currently, some tests are failing because

- i'm not sure what the "correct" formatting is
- and how to handle spaces (especially newlines)

Perhaps it's OK to ignore newlines for now, and just always start with
`{<space>` and close with `<space>}`?
2019-11-13 22:10:49 +01:00
Richard Feldman
ebaed27193 Parse if and args w/ idents, format w/ parens 2019-10-04 11:50:19 +03:00
Richard Feldman
9a564df7bb Collapse multiple blank lines in formatter 2019-10-03 17:02:28 +03:00