zig-spec icon indicating copy to clipboard operation
zig-spec copied to clipboard

Labeled block not allowed as lhs of assignment at statement level

Open Hejsil opened this issue 7 years ago • 0 comments

Explained here

Actually, this broke with the grammar changes in #1685. Basically, we have this rule at stmt level:

Statement
    <- ...
     / LabeledStatement
     ...
     / AssignExpr SEMICOLON

LabeledStatement <- BlockLabel? (Block / LoopStatement)

AssignExpr expands into all other expressions. LabeledStatement is before AssignExpr so that rule is being parsed first, succeeds and then Statement succeeds. Then the parser tries to end the __case_1 block, which then fails the parsing.

The parser parses the grammar correctly, but the new grammar just does not allow this syntax. I can't come up with a solution on top of my head right now.

Edit: Well, a solution would be to make translate-c conform to this new grammar. Idk if we want to put in the work to make x:{}.* = 1; valid at stmt level.

Hejsil avatar Mar 18 '19 14:03 Hejsil