Simple, Efficient, Sound and Complete Combinator Parsing for All Context-Free Grammars, Using an Oracle
Parsers for context-free grammars can be implemented directly and naturally in a functional style known as “combinator parsing”, using recursion following the structure of the grammar rules. Traditionally parser combinators have struggled to handle all features of context-free grammars, such as left recursion.
Previous work introduced novel parser combinators that could be used to parse all context-free grammars. A parser generator built using these combinators was proved both sound and complete in the HOL4 theorem prover. Unfortunately the performance was not as good as other parsing methods such as Earley parsing.
In this paper, we build on this previous work, and combine it in novel ways with existing parsing techniques such as Earley parsing. The result is a sound-and-complete combinator parsing library that can handle all context-free grammars, and has good performance.
KeywordsParse Tree Input String Grammar Rule Start Symbol Middle Component
Unable to display preview. Download preview PDF.
- 1.Happy, a parser generator for Haskell, http://www.haskell.org/happy/
- 2.Aho, A.V., Ullman, J.D.: The theory of parsing, translation, and compiling. Prentice-Hall, Inc. (1972)Google Scholar
- 3.Atkey, R.: The semantics of parsing with semantic actions. In: LICS 2012, pp. 75–84. IEEE (2012)Google Scholar
- 4.Barthwal, A., Norrish, M.: A mechanisation of some context-free language theory in HOL4. Journal of Computer and System Sciences (2013)Google Scholar
- 6.Ford, B.: Packrat parsing: simple, powerful, lazy, linear time, functional pearl. In: ICFP 2002, pp. 36–47. ACM (2002)Google Scholar
- 9.Kasami, T.: An efficient recognition and syntax analysis algorithm for context-free languages. Tech. Rep. AFCRL-65-758, Air Force Res. Lab., Massachusetts (1965)Google Scholar
- 11.Ljunglöf, P.: Pure functional parsing. Göteborg University and Chalmers University of Technology, Gothenburg (2002)Google Scholar
- 12.Pratt, V.R.: Top down operator precedence. In: Proceedings ACM Symposium on Principles Prog. Languages (1973)Google Scholar
- 16.Tomita, M.: LR parsers for natural languages. In: Proc. of the 10th Int. Conf. on Computational linguistics, pp. 354–357. ACL (1984)Google Scholar