I have a parser that was written using Scala's RegexParsers
- link
It had some serious performance problems when parsing a grammar which had deeply nested expressions. As such I have created a version where I mix in Scala's PackratParsers
- link
The Packrat version does not exhibit the same performance issue and correctly parses the grammar. However, when I provide an invalid grammar for testing, e.g. this
The old (non-packrat) parser used to correctly report the 'Invalid rule' failure, via the failure parser combinator | failure("Invalid rule")
here - link
When using the packrat-parser version, if I enable tracing I can see from the trace that the failure is created just as it is in the non-packrat version, however the PackratParser seems to ignore this and always return failure: Base Failure
instead.
Is there something different about failure handling when using PackratParsers which I need to understand?
err("Invalid rule")
instead offailure("Invalid rule")
then because backtracking has stopped, many of my other rules that were previously valid start returningerr("Invalid rule")
which is not correct. – Ebsen