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

Accelerator readme doesn't give useful examples of acceleration #145

Closed rcrogers closed 8 years ago

rcrogers commented 8 years ago

https://github.com/kschiess/parslet/blob/9afeb3ca5ce7f83786f9a78cb5dca06a199b29f3/qed/accelerators.md#bindings-and-actions

Not sure if this is an oversight or just unfinished, but I couldn't find an example of how an accelerator can actually speed up parsing, e.g. an example implementation of GobbleUp. Will it always involve creating a custom Atom class?

These would also be useful:

rcrogers commented 8 years ago

I found GobbleUp: https://github.com/kschiess/parslet/blob/66e242841ea27554a64f42d52093c1f41bc56e1e/qed/applique/gobbleup.rb

Do accelerators just boil down to finding a faster method like StringScanner#check_until?

kschiess commented 8 years ago

Honestly, I've ran into a design roadblock with accelerators - and have let it rest since then. The issue is that we want to support lazy evaluation across rule barriers - and that collides with acceleration.

The most potential for speeding up parsers I see in creating custom 'partial' parsers aka atom classes. But if you really need to go fast - don't use ruby. Simple as that.

rcrogers commented 8 years ago

All good to know, thanks for the response!

kschiess commented 8 years ago

Welcome! (closing this)