3 ms·
The original Packrat parser explicitly defines it as using memoisation: > Packrat parsing provides the simplicity, elegance, and generality of the backtracking
by klmr 9y ago
The original Packrat parser explicitly defines it as using memoisation:
> Packrat parsing provides the simplicity, elegance, and generality of the backtracking model, but eliminates the risk of super-linear parse time, by saving all intermediate parsing results as they are computed and ensuring that no result is evaluated more than once.[1]
And just to get a potential misunderstanding out of the way: I’m not claiming that PEGs are formally distinct from recursive descent: According to my understanding (but unlike you I’ve never implemented the packrat algorithm itself … though I’ve written plenty of recursive descent parsers and some PEG-based parsers) there’s a 1:1 correspondence between nonterminals in PEG, and a function in the recursive descent parser. The difference is that one is a formal grammar for describing parsers, while the other is the actual parser implementation.
[1] https://paperpile.com/app/p/3c6d20f0-ab15-0b13-b809-1fdf4ac758b1 https://paperpile.com/app/p/3c6d20f0-ab15-0b13-b809-1fdf4ac7...