Back to Search Start Over

DCGs + Memoing = Packrat Parsing but Is It Worth It?

Authors :
Ralph Becket
Zoltan Somogyi
Source :
Practical Aspects of Declarative Languages ISBN: 9783540774419, PADL
Publication Year :
2007
Publisher :
Springer Berlin Heidelberg, 2007.

Abstract

Packrat parsing is a newly popular technique for efficiently implementing recursive descent parsers. Packrat parsing avoids the potential exponential costs of recursive descent parsing with backtracking by ensuring that each production rule in the grammar is tested at most once against each position in the input stream. This paper argues that (a) packrat parsers can be trivially implemented using a combination of definite clause grammar rules and memoing, and that (b) packrat parsing may actually be significantly less efficient than plain recursive descent with backtracking, but (c) memoing the recognizers of just one or two nonterminals, selected in accordance with Amdahl's law, can sometimes yield speedups. We present experimental evidence to support these claims.

Details

ISBN :
978-3-540-77441-9
ISBNs :
9783540774419
Database :
OpenAIRE
Journal :
Practical Aspects of Declarative Languages ISBN: 9783540774419, PADL
Accession number :
edsair.doi...........34fba7fcf8b7a297c3c224403c71e89e
Full Text :
https://doi.org/10.1007/978-3-540-77442-6_13