Closed jorendorff closed 4 years ago
One idea I had for jsparagus generally was the ability to mark any point in any production and say "this right here is a special position" and give the specialness a name, like:
IterationStatement ::= "do" Statement "while" "(" Expression ")" [label:magic_asi] ";"
And at run time, if an error happens, such states get a special error handler. This feature would fit the theme of jsparagus being "the hackable LALR parser generator".
However, two caveats:
Maybe yacc-styleerror
productions are better.
It's not clear how general this mechanism would end up being. I go back and forth between only wanting it for do-while and thinking it could solve all of ASI.
Error productions are better, can be trivially generated from the standard grammar, and can implement all the ASI quirks except "[no LineTerminator here]" and for (let x=0 x<n; x++)
.
Ticked the last checkbox in #128.
There are so many bits and pieces here:
}
for(;;)
loop headfor (let x = 0 \n x < 4; x++) {}
.