Parser Combinators for Ambiguous Left-Recursive Grammars

  • Richard A. Frost
  • Rahmatullah Hafiz
  • Paul Callaghan
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4902)


Parser combinators are higher-order functions used to build parsers as executable specifications of grammars. Some existing implementations are only able to handle limited ambiguity, some have exponential time and/or space complexity for ambiguous input, most cannot accommodate left-recursive grammars. This paper describes combinators, implemented in Haskell, which overcome all of these limitations.


Parser combinators ambiguity left recursion functional programming natural-language parsing 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aho, A.V., Ullman, J.D.: The Theory of Parsing, Translation, and Compiling, vol. I: Parsing. Prentice-Hall, Englewood Cliffs (1972)Google Scholar
  2. 2.
    Burge, W.H.: Recursive Programming Techniques. Addison-Wesley, Reading (1975)zbMATHGoogle Scholar
  3. 3.
    Carroll, J.: Efficiency in large-scale parsing systems – parser comparison (2003),
  4. 4.
    Earley, J.: An efficient context-free parsing algorithm. Communications of the ACM 13(2), 94–102 (1970)zbMATHCrossRefGoogle Scholar
  5. 5.
    Fairburn, J.: Making form follow function: An exercise in functional programming style. Cambridge Comp. Lab. Technical Report No. 89 (1986)Google Scholar
  6. 6.
    Ford, B.: Packrat parsing: Simple, powerful, lazy, linear time. In: ICFP, pp. 36–47 (2002)Google Scholar
  7. 7.
    Frost, R.A.: Realization of natural language interfaces using lazy functional programming. ACM Comp. Surv. 38(4) Article 11 (2006)Google Scholar
  8. 8.
    Frost, R.A.: Using memoization to achieve polynomial complexity of purely functional executable specifications of non-deterministic top-down parsers. SIGPLAN Notices 29(4), 23–30 (1994)CrossRefGoogle Scholar
  9. 9.
    Frost, R.A., Hafiz, R., Callaghan.: Modular and efficient top-down parsing for ambiguous left-recursive grammars. In: Proc. of the Tenth Int. Conf. on Parsing Technologies, pp. 109–120. ACL Press (2007)Google Scholar
  10. 10.
    Frost, R.A., Hafiz, R.: A new top-down parsing algorithm to accommodate ambiguity and left recursion in polynomial time. SIGPLAN Notices 42(5), 46–54 (2006)CrossRefGoogle Scholar
  11. 11.
    Hutton, G., Meijer, E.: Monadic parser combinators. J. of Functional Programming 8(4), 437–444 (1995)CrossRefGoogle Scholar
  12. 12.
    Johnson, M.: Squibs and discussions: Memoization in top-down parsing. Computational Linguistics 21(3), 405–417 (1995)Google Scholar
  13. 13.
    Kuno, S.: The augmented predictive analyzer for context-free languages — its relative efficiency. Communications of the ACM 9(11), 810–823 (1966)zbMATHCrossRefGoogle Scholar
  14. 14.
    Lickman, P.: Parsing With Fixed Points. Master’s Th., Oxford (1995)Google Scholar
  15. 15.
    Nederhof, M.J., Koster, C.H.A.: Top-down parsing for left-recursive grammars. Technical Report 93–10. Research Institute for Declarative Systems, Department of Informatics, Faculty of Mathematics and Informatics, Katholieke Universiteit, Nijmegen (1993)Google Scholar
  16. 16.
    Norvig, P.: Techniques for automatic memoization with applications to context-free parsing. Computational Linguistics 17(1), 91–98 (1991)Google Scholar
  17. 17.
    Shiel, B.A.: Observations on context-free parsing. Technical Reports TR 12–76, Center for Research in Computing Technology, Aiken Computational Laboratory, Harvard University (1976)Google Scholar
  18. 18.
    Tomita, M.: Efficient Parsing for Natural Language: A Fast Algorithm for Practical Systems. Kluwer Academic Publishers, Boston, MA (1986)Google Scholar
  19. 19.
    Wadler, P.: How to replace failure by a list of successes. In: Jouannaud, J.-P. (ed.) Functional Programming Languages and Computer Architecture. LNCS, vol. 201, pp. 113–128. Springer, Heidelberg (1985)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Richard A. Frost
    • 1
  • Rahmatullah Hafiz
    • 1
  • Paul Callaghan
    • 2
  1. 1.School of Computer ScienceUniversity of WindsorCanada
  2. 2.Department of Computer ScienceUniversity of DurhamU.K.

Personalised recommendations