Implement Throw and Label operations
DavidSouther opened this issue · comments
https://arxiv.org/pdf/1806.11150.pdf with proof of concept in https://github.com/sqmedeiros/lpeglabel
We propose a conservative extension, based on PEGs with labeled failures, that adds a syntax error recovery mechanism for
PEGs. �is extension associates recovery expressions to labels, where a label now not only reports a syntax error but also uses this recovery expression to reach a synchronization point in the input
and resume parsing.
The syntax using ^ as the synchronization operator feels fairly clean? I'm not sure whether throw should be %{l} or, better, Throw to make it obvious. One would require special casing syntax; the other, special casing a function. ListOf sort of does that? but IIRC the semantics phase, not in the grammar.
Some overlap with #302 here, and I don't know if this would affect #158 if one were to try to resynchronize to the proposed @rules.