Re:Owl: Parser generator for visibly pushdown languages
by nickpsecurity on Wednesday November 07, 2018 @01:45PM
(#18401168)
I'll also add you can use two parsers: one that's super fast on code that's correctly written; if that fails, one that makes error messages easy to handle. sklogic said he used that strategy in his tools for program analysis. The extra code is negligible. I don't know how much extra time or maintenance burden but I figured marginal versus cost of handling errors in first place.
[ Parent
| on HN ]
Re:Owl: Parser generator for visibly pushdown languages
by lihaoyi on Wednesday November 07, 2018 @02:59PM
(#18401878)
My FastParse (https://www.lihaoyi.com/fastparse/) parser combinator library does this; by default it runs without error logging, just giving you an error position, but if something fails you can ask it to re-do the parse keeping track of additional metadata to give you a nice error message with what tokens could have succeeded and a stack trace telling you why wants those tokens.
Tracing errors slows things down about 2x, which is why it isnt on by default, on the assumption that most parses are successful