Hacker News new | ask | show | jobs
by stormbrew 3602 days ago
Also worth noting from this paper is this, which is an underappreciated facet of packrat parsing:

> It should be noted that while Packrat parsing obviously adds an extra layer of complexity over ‘pure’ PEGs, contrary to expectations it often slows parsing down when used blindly for every rule.

Especially these days, and really definitely in a lot of dynamic languages (cfe Ruby), the kind of allocation rate that packrat parsing produces has a significantly negative effect on performance. Applied blindly you're just trading n^2 performance for n^2 memory use, and that may not work out the way you think it should.

1 comments

Actually performance is exponential without memoization, so usually some amount of memoization is essential, but memoizing more rules usually does not help.