HackerPapers

arXiv:1604.04695cs.PL

On the Complexity and Performance of Parsing with Derivatives

Michael D. Adams, Celeste Hollenbeck, Matthew Might

Abstract

Current algorithms for context-free parsing inflict a trade-off between ease of understanding, ease of implementation, theoretical complexity, and practical performance. No algorithm achieves all of these properties simultaneously. Might et al. (2011) introduced parsing with derivatives, which handles arbitrary context-free grammars while being both easy to understand and simple to implement. Despite much initial enthusiasm and a multitude of independent implementations, its worst-case complexity has never been proven to be better than exponential. In fact, high-level arguments claiming it is fundamentally exponential have been advanced and even accepted as part of the folklore. Performance ended up being sluggish in practice, and this sluggishness was taken as informal evidence of exponentiality. In this paper, we reexamine the performance of parsing with derivatives. We have discovered that it is not exponential but, in fact, cubic. Moreover, simple (though perhaps not obvious) modifications to the implementation by Might et al. (2011) lead to an implementation that is not only easy to understand but also highly performant in practice.

arXiv comments
13 pages; 12 figures; implementation at http://bitbucket.org/ucombinator/parsing-with-derivatives/ ; published in PLDI '16, Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation, June 13 - 17, 2016, Santa Barbara, CA, USA
Journal reference
DOI
doi:10.1145/2908080.2908128
Subjects
cs.PLProgramming Languages

On Hacker News

Linked by 2 identifiable commenters in 2 comments across 2 threads, from Jul 2019 to May 2023. Found in 1 HN submission from Jun 2016 to Jun 2016. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments2 threads

    • There is more to translation of text to AST than parsing and lexing. There are semantic checks. In addition, most languages are not CFG and require nested contexts. "#{"\tThis is some #{'damn'} string".to_upper_case + " hello"}\n" Also, there are lexerless parsers such as…

      1letterunixnameView on HNParent context

    • Neat. Has anyone seen Parsing with Derivatives (2011) ? https://youtu.be/WPde6DDLtXg http://matt.might.net/papers/might2011derivatives.pdf https://blog.klipse.tech/clojure/2016/10/02/parsing-with-der... https://elfsternberg.com/2018/01/24/parsing-derivatives-naiv...…

      dfeojm-zlibView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.