mozilla-spidermonkey / jsparagus

Experimental JS parser-generator project.
Other
448 stars 20 forks source link

Implement ASI in js_parser/parser.py #4

Closed jorendorff closed 4 years ago

jorendorff commented 5 years ago

There are so many bits and pieces here:

jorendorff commented 5 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:

jorendorff commented 5 years ago

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++).

jorendorff commented 4 years ago

Ticked the last checkbox in #128.