Commit graph

130 commits

Author SHA1 Message Date
Richard Feldman
a4e238b09c Merge remote-tracking branch 'origin/trunk' into case-multi-patterns 2020-01-11 13:10:09 -05:00
Richard Feldman
e49b608157 Get Switch running on Crane 2020-01-10 01:54:32 -05:00
Stoeffel
8170d51e4e parse space around patterns not just before
separaters shouldn't eat spaces, because they might get lost this way.
2020-01-09 17:50:54 +01:00
Stoeffel
8809082f11 zero or more spaces not one
We should allow writing `Foo|Bar`
2020-01-09 17:47:12 +01:00
Stoeffel
4ac5d11e62 format cases 2020-01-09 17:35:16 +01:00
Folkert
dd240cf53a typecheck tags with arguments
also fixes an issue where private tags in patterns would not have the @ symbol in their name
2020-01-09 13:20:21 +01:00
Richard Feldman
72ba7310ce Fix nested applied tag pattern parsing bug 2020-01-08 22:23:36 -05:00
Richard Feldman
5f04aa7600 Fix applied tag pattern parsing 2020-01-08 22:15:36 -05:00
Stoeffel
33e9a545fc update TODOs 2020-01-08 19:03:23 +01:00
Stoeffel
5744e329ac remove unused keyword 2020-01-08 19:03:13 +01:00
Stoeffel
d8923968cf add some TODOs with questions 2020-01-08 13:04:10 +01:00
Stoeffel
150b75721c allow alternatives on all branches. 2020-01-08 12:58:40 +01:00
Stoeffel
a98113c88d don't use a tuple to ensure non-emptiness 2020-01-08 11:05:53 +01:00
Stoeffel
64a562ebc6 no need for spaces between alternatives
allow the following:

  when animal is
    Dog|Fox -> "bark"
2020-01-08 09:34:51 +01:00
Stoeffel
505effd1d9 basic parsing of alternative cases in when .. in 2020-01-08 08:53:48 +01:00
Stoeffel
3a1d905b66 one or more patterns in branches
Modify ast to allow mutliple pattern per branch in when.

  when animal is
    Dog x | Fox x => "bark"
    Cat x => "miau"
2020-01-08 06:39:25 +01:00
Richard Feldman
3ce46ead2d Remove OptionalField from AST 2020-01-06 21:36:38 -05:00
Richard Feldman
2eb6fb2046 Reuse tag_pattern() 2020-01-05 14:20:48 -05:00
Richard Feldman
b175e10678 Fix global_tag parser 2020-01-05 14:20:48 -05:00
Richard Feldman
748d57f523 Parse record updates 2020-01-05 00:36:49 -05:00
Folkert
c4971675eb add OptionalField constructor 2019-12-30 00:50:28 +01:00
Richard Feldman
fd36e153ed
Merge branch 'trunk' into ct/case-when-to-when-is 2019-12-23 23:29:43 -08:00
Chad Stearns
844ca0a50e Changed instances of 'Case' in the code to 'When' 2019-12-23 17:41:19 -05:00
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
Folkert
9c78d29a2f Fix parsing issue
I made this follow the test, but that may not actually be the desired
approach.

So the question is what the region of an identifier in a pattern is.
Previously this was

    { x }
      ^

Using the new parser it became

    { x }
      ^^

Which this commit corrects to the old state by using the region from an
AssignedField.
2019-12-23 22:39:12 +01:00
Folkert
1b2636bee6 parse guarded record patterns
e.g.

    case foo when
        { x: 4 } -> ...
        { x, y } -> ...
2019-12-23 21:52:12 +01:00
Folkert
9d7ce6ff15 parse records with type signatures
{ x, y } : { x : Int, y : Float }
2019-12-22 20:23:12 +01:00
Folkert
a5cf0fc505 Parse field access after record literal
e.g. `{ x: 4 }.x` now parses. This is of limited practical use of course
but I would expect this to work based on the signature of `.x`.
2019-12-19 16:50:55 +01:00
Richard Feldman
d0fa8bf857 Use commas between function arguments 2019-12-18 21:50:45 -05:00
Richard Feldman
07adfafd47 Remove some unnecessary stuff - thanks, clippy! 2019-12-16 21:29:03 -05:00
Richard Feldman
d73b8ca1fc Remove UnqualifiedIdent 2019-12-16 21:29:03 -05:00
Richard Feldman
db6f80f358 Go deeper on UnqualifiedIdent 2019-12-16 21:29:03 -05:00
Richard Feldman
533d68691f Revert "Try a desugared module"
This reverts commit 9a2278e22d.
2019-12-16 21:29:03 -05:00
Richard Feldman
5589875453 Try a desugared module 2019-12-16 21:29:03 -05:00
Folkert
502021d955 Always parse type signatures in let blocks.
Formerly, this would not parse

    foo : Int
    foo = 4

While this would

    bar = 3
    foo : Int
    foo = 4

Now, the first def can also be a type annotation.

This change performs some code duplication. This can probably be
abstracted/unified, but I'm not sure how to do that in a clean way.
2019-12-13 19:53:46 +01:00
Richard Feldman
2710dcb95c Fix parsing hex/octal/binary literals 2019-12-07 02:27:12 -05:00
Richard Feldman
19885d32c1 Revise parse::ast::Defs
Add Nested, drop CustomType and TypeAlias
2019-12-05 19:51:50 -05:00
Richard Feldman
be810f4dc9 Add restricted keyword 'as' 2019-12-05 19:34:31 -05:00
Richard Feldman
a57c3d6ec8 Do what clippy says 2019-12-02 22:19:09 -05:00
Richard Feldman
1d18f4cc85 Use private/global tags and Access over Field 2019-12-02 18:36:59 -05:00
Richard Feldman
68aa33d8ba Introduce Expr::Nested 2019-12-01 19:42:41 -05:00
Richard Feldman
be1e83dd6d Use crate:: prefix a bunch. 2019-11-27 22:11:40 -05:00
Richard Feldman
90d463873e Drop type_limit 2019-11-25 22:19:33 -05:00
Richard Feldman
0d69d7e90f Add one_of! combinator 2019-11-25 21:32:11 -05:00
Richard Feldman
4926bfbc3a Reorganize fmt and module 2019-11-25 20:42:44 -05:00
Richard Feldman
ed23e23a54 Rename unqualified_ident to lowercase 2019-11-25 16:25:49 -05:00
Richard Feldman
8e0fb89f66 Introduce Expr::ParensAround 2019-11-22 00:21:32 -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
Folkert
56e0947646 remove inaccurate comment
patterns in a record destructure can now be any arbitrary pattern,
rather than just identifiers.
2019-11-21 13:04:23 +01:00