Skip to content

Comment on A quick intro to writing a parser with Treetopparent

Comments

LPEG is actually quite fast. (Often as fast or faster than well-tuned regexp implementations.)

In general, Lua is usually faster than Ruby and JS because the language itself seems to have been engineered with a very clear understanding of where the language could be expressive/dynamic without unnecessarily sacrificing efficiency, and it's had a long time to mature. LPEG was written by one of the primary Lua authors, and it shows.

If you're geeked about PEGs, I highly recommend reading the paper and then the source. There are some details specific to the Lua C API, but it shouldn't be that hard to port or understand in isolation.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.