qwertie / ecsharp

Home of LoycCore, the LES language of Loyc trees, the Enhanced C# parser, the LeMP macro preprocessor, and the LLLPG parser generator.
http://ecsharp.net
Other
172 stars 25 forks source link

LES3: Eliminate labels? #92

Closed qwertie closed 4 years ago

qwertie commented 5 years ago

LES3 currently supports labels (technically the suffix-colon operator):

    .if hungry {
        .eat
        .goto consideredHarmful
    } elseif playful {
        .play
      consideredHarmful:
        .rest
    } else {
        .shrug
    }

A newline (or semicolon) is required after : to indicate it's a label.

I think I supported labels because one of the WebAssembly guys wanted them and preferred the traditional syntax... but it seems like a prefix-colon would work pretty much just as well.

    .if hungry {
        .eat
        .goto consideredHarmful
    } elseif playful {
        .play
      :consideredHarmful
        .rest
    } else {
        .shrug
    }

Removing labels would have two benefits:

  1. It would simplify the parser
  2. JSON is more likely to be parseable, since : would be a binary operator in this code:

    { "key":
      "value" }

However LES3 would still not really be JSON-compatible since line breaks remain significant in other cases such as this:

{ "key"
  :"value" }
qwertie commented 4 years ago

Label support will be gone in v28.0 / 2.8.0.