kschiess / parslet

A small PEG based parser library. See the Hacking page in the Wiki as well.
kschiess.github.com/parslet
MIT License
805 stars 95 forks source link

Is it possible to access tree output when parse fails? #196

Closed rupy closed 5 years ago

rupy commented 5 years ago

Hi, I'd like to know if I can access tree output built by "as" at that moment when parse fails. if so, debug becomes much easier.

Any help will be appreciated.

kschiess commented 5 years ago

Tree output can only be constructed once a parse succeeds. Otherwise the output is underdetermined, there would be many trees to consider. Have a look at

https://github.com/kschiess/parslet/blob/master/example/deepest_errors.rb

for how to use alternative error reporters. Also - the implementation of that error reporter could be interesting to you; maybe you want to contribute another one?