A Graphical Model for Context-Free Grammar Parsing

  • Keshav PingaliEmail author
  • Gianfranco Bilardi
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9031)


In the compiler literature, parsing algorithms for context-free grammars are presented using string rewriting systems or abstract machines such as pushdown automata. Unfortunately, the resulting descriptions can be baroque, and even a basic understanding of some parsing algorithms, such as Earley’s algorithm for general context-free grammars, can be elusive. In this paper, we present a graphical representation of context-free grammars called the Grammar Flow Graph (GFG) that permits parsing problems to be phrased as path problems in graphs; intuitively, the GFG plays the same role for context-free grammars that nondeterministic finite-state automata play for regular grammars. We show that the GFG permits an elementary treatment of Earley’s algorithm that is much easier to understand than previous descriptions of this algorithm. In addition, look-ahead computation can be expressed as a simple inter-procedural dataflow analysis problem, providing an unexpected link between front-end and back-end technologies in compilers. These results suggest that the GFG can be a new foundation for the study of context-free grammars.


Parse Tree Input String Start Node Input Word Rule Instance 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Reynolds, J.C.: On the relation between direct and continuation semantics. In: Loeckx, I.J. (ed.) ICALP 1974. LNCS, vol. 14, pp. 141–156. Springer, Heidelberg (1974)CrossRefGoogle Scholar
  2. 2.
    Sussman, G., Steele, G.: Scheme: An interpreter for extended lambda calculus. Technical Report AI Memo 349, AI Lab, M.I.T. (December 1975)Google Scholar
  3. 3.
    Earley, J.: An efficient context-free parsing algorithm. Commun. ACM 13(2), 94–102 (1970)CrossRefzbMATHGoogle Scholar
  4. 4.
    Aho, A., Lam, M., Sethi, R., Ullman, J.: Compilers: principles, techniques, and tools. Addison Wesley (2007)Google Scholar
  5. 5.
    Grune, D., Jacobs, C.: Parsing Techniques: A practical guide. Springer (2010)Google Scholar
  6. 6.
    Cousot, P., Cousot, R.: Parsing as abstract interpretation of grammar semantics. Theoret. Comput. Sci. 290, 531–544 (2003)CrossRefzbMATHMathSciNetGoogle Scholar
  7. 7.
    Woods, W.A.: Transition network grammars for natural language analysis. Commun. ACM 13(10) (October 1970)Google Scholar
  8. 8.
    Parr, T., Fisher, K.: LL(*): The foundation of the ANTLR parser generator. In: PLDI (2011)Google Scholar
  9. 9.
    Yannakakis, M.: Graph-theoretic methods in database theory. In: Principles of Database Systems (1990)Google Scholar
  10. 10.
    Sippu, S., Soisalon-Soininen, E.: Parsing theory. Springer (1988)Google Scholar
  11. 11.
    Sharir, M., Pnueli, A.: Two approaches to interprocedural dataflow analysis. In: Program Flow Analysis: Theory and Applications, pp. 189–234. Prentice-Hall (1981)Google Scholar
  12. 12.
    Cormen, T., Leiserson, C., Rivest, R., Stein, C. (eds.): Introduction to Algorithms. MIT Press (2001)Google Scholar
  13. 13.
    Hopcroft, J.E., Motwani, R., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation, 3rd edn. Addison-Wesley Longman Publishing Co., Inc., Boston (2006)Google Scholar
  14. 14.
    Clinger, W.D., Halpern, C.: Alternative semantics for mccarthy’s amb. In: Brookes, S.D., Roscoe, A.W., Winskel, G. (eds.) Seminar on Concurrency. LNCS, vol. 197, pp. 467–478. Springer, Heidelberg (1985)CrossRefGoogle Scholar
  15. 15.
    Terese: Term Rewriting Systems. Combridge University Press (2003)Google Scholar
  16. 16.
    Graham, S.L., Ruzzo, W.L., Harrison, M.: An improved context-free recognizer. ACM TOPLAS 2(3), 415–462 (1980)CrossRefzbMATHGoogle Scholar
  17. 17.
    Aycock, J., Horspool, N.: Practical Earley parsing. The Computer Journal 45(6), 620–630 (2002)CrossRefzbMATHGoogle Scholar
  18. 18.
    Perlin, M.: LR recursive transition networks for Earley and Tomita parsing. In: ACL 1991 (1991)Google Scholar
  19. 19.
    Pereira, F.C.N., Warren, D.: Parsing as deduction. In: 21st Annual Meeting of the Association for Computational Linguistics, pp. 137–144. MIT, Cambridge (1983)CrossRefGoogle Scholar
  20. 20.
    Shieber, S.M., Schabes, Y., Pereira, F.C.N.: Principles and implementation of deductive parsing. Journal of Logic Programming 24(1 & 2), 3–36 (1995)CrossRefzbMATHMathSciNetGoogle Scholar
  21. 21.
    Sikkel, K.: Parsing Schemata. Texts in Theoretical Computer Science. Springer, Heidelberg (1997)CrossRefzbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  1. 1.The University of TexasAustinUSA
  2. 2.Università di PadovaPadovaItaly

Personalised recommendations