fmease / lushui

The reference compiler of the Lushui programming language
Apache License 2.0
5 stars 0 forks source link

Parsing issues around expressions which contain indentation #36

Closed fmease closed 3 years ago

fmease commented 3 years ago

Expressions which contain indentation are currently let/in, case/of and do blocks (probably expanding). It's a reoccurring issue with our horrendous indentation system #15 which we should probably replace.

I am actually not sure if they should parse (we don't have a specification yet). But those three examples below should parse but don't:

Let/in:

alpha: Alpha = let alpha = alpha in
    alpha

Diagnostic:

error[E010]: found indentation, but expected expression
  > test.lushui:6:1
  |
6 |     x
  | ^^^^

Case/of (error does not happen if there is no declaration below the one containing the case analysis):

alpha: Alpha = case alpha of
    alpha => alpha

beta

Diagnostic:

error[E010]: found identifier, but expected line break
   > test.lushui:11:1
   |
11 | beta
   | ^^^^ 

Do blocks (error does not happen if there is no declaration below the one containing the case analysis):

alpha: Alpha = do
    alpha <- alpha

beta

Diagnostic:

error[E010]: found identifier, but expected line break
  > test.lushui:8:1
  |
8 | beta
  | ^^^^ 

Each of them can be slightly rewritten that is indented to make them parse:

alpha: Alpha =
    let alpha = alpha in
    alpha
alpha: Alpha =
    case alpha of
        alpha => alpha

beta
alpha: Alpha =
    do
        alpha <- alpha

beta
fmease commented 3 years ago

Fixed by #87.