Skip to main content

Faster, Practical GLL Parsing

  • Conference paper

Part of the Lecture Notes in Computer Science book series (LNTCS,volume 9031)

Abstract

Generalized LL (GLL) parsing is an extension of recursivedescent (RD) parsing that supports all context-free grammars in cubic time and space. GLL parsers have the direct relationship with the grammar that RD parsers have, and therefore, compared to GLR, are easier to understand, debug, and extend. This makes GLL parsing attractive for parsing programming languages.

In this paper we propose a more efficient Graph-Structured Stack (GSS) for GLL parsing that leads to significant performance improvement. We also discuss a number of optimizations that further improve the performance of GLL. Finally, for practical scannerless parsing of programming languages, we show how common lexical disambiguation filters can be integrated in GLL parsing.

Our new formulation of GLL parsing is implemented as part of the Iguana parsing framework. We evaluate the effectiveness of our approach using a highly-ambiguous grammar and grammars of real programming languages. Our results, compared to the original GLL, show a speedup factor of 10 on the highly-ambiguous grammar, and a speedup factor of 1.5, 1.7, and 5.2 on the grammars of Java, C#, and OCaml, respectively.

References

  1. Knuth, D.E.: On the Translation of Languages from Left to Right. Information and Control 8(6), 607–639 (1965)

    CrossRef  MathSciNet  Google Scholar 

  2. Deremer, F.L.: Practical Translators for LR(k) Languages. PhD thesis, Massachusetts Institute of Technology (1969)

    Google Scholar 

  3. Johnson, S.C.: Yacc: Yet Another Compiler-Compiler AT&T Bell Laboratories, http://dinosaur.compilertools.net/yacc/

  4. Gosling, J., Joy, B., Steele, G.L.: The Java Language Specification, 1st edn. Addison-Wesley Longman Publishing Co., Inc, Boston (1996)

    MATH  Google Scholar 

  5. Tomita, M.: Efficient Parsing for Natural Language: A Fast Algorithm for Practical Systems. Kluwer Academic Publishers, Norwell (1985)

    Google Scholar 

  6. McPeak, S., Necula, G.C.: Elkhound: A Fast, Practical GLR Parser Generator. In: Duesterwald, E. (ed.) CC 2004. LNCS, vol. 2985, pp. 73–88. Springer, Heidelberg (2004)

    CrossRef  Google Scholar 

  7. van den Brand, M., Heering, J., Klint, P., Olivier, P.A.: Compiling language definitions: The ASF+SDF compiler. ACM Trans. Program. Lang. Syst. 24 (2002)

    Google Scholar 

  8. Scott, E., Johnstone, A.: GLL parse-tree generation. Science of Computer Programming 78(10), 1828–1844 (2013)

    CrossRef  Google Scholar 

  9. Johnson, M.: The Computational Complexity of GLR Parsing. In: Tomita, M. (ed.) Generalized LR Parsing, pp. 35–42. Springer US (1991)

    Google Scholar 

  10. Johnstone, A., Scott, E.: Modelling GLL parser implementations. In: Malloy, B., Staab, S., van den Brand, M. (eds.) SLE 2010. LNCS, vol. 6563, pp. 42–61. Springer, Heidelberg (2011)

    CrossRef  Google Scholar 

  11. Salomon, D.J., Cormack, G.V.: Scannerless NSLR(1) Parsing of Programming Languages. In: Programming Language Design and Implementation, PLDI 1989, pp. 170–178 (1989)

    Google Scholar 

  12. Visser, E.: Scannerless Generalized-LR Parsing. Technical report, University of Amsterdam (1997)

    Google Scholar 

  13. Bravenboer, M., Tanter, É., Visser, E.: Declarative, Formal, and Extensible Syntax Definition for AspectJ. In: Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2006, pp. 209–228 (2006)

    Google Scholar 

  14. den van Brand, M.G.J., Scheerder, J., Vinju, J.J., Visser, E.: Disambiguation Filters for Scannerless Generalized LR Parsers. In: Nigel Horspool, R. (ed.) CC 2002. LNCS, vol. 2304, pp. 143–158. Springer, Heidelberg (2002)

    CrossRef  Google Scholar 

  15. Gosling, J., Joy, B., Steele, G., Bracha, G., Buckley, A.: The Java Language Specification Java SE 7 Edition (February 2013)

    Google Scholar 

  16. Microsoft Corporation: C# Language Specification Version 5.0 (2013)

    Google Scholar 

  17. Leroy, X., Doligez, D., Frisch, A., Garrigue, J., Rémy, D., Vouillon, J.: The OCaml system release 4.01: Documentation and user’s manual (September 2013)

    Google Scholar 

  18. Afroozeh, A., van den Brand, M., Johnstone, A., Scott, E., Vinju, J.: Safe Specification of Operator Precedence Rules. In: Erwig, M., Paige, R.F., Van Wyk, E. (eds.) SLE 2013. LNCS, vol. 8225, pp. 137–156. Springer, Heidelberg (2013)

    CrossRef  Google Scholar 

  19. Johnstone, A., Scott, E., Economopoulos, G.: Generalised parsing: Some costs. In: Duesterwald, E. (ed.) CC 2004. LNCS, vol. 2985, pp. 89–103. Springer, Heidelberg (2004)

    CrossRef  Google Scholar 

  20. Nozohoor-Farshi, R.: GLR Parsing for ε-Grammers. In: Tomita, M. (ed.) Generalized LR Parsing, pp. 61–75. Springer US (1991)

    Google Scholar 

  21. Scott, E., Johnstone, A.: Right Nulled GLR Parsers. ACM Trans. Program. Lang. Syst. 28(4), 577–618 (2006)

    CrossRef  Google Scholar 

  22. Aycock, J.: Faster Generalized LR Parsing. In: Jähnichen, S. (ed.) CC 1999. LNCS, vol. 1575, pp. 32–46. Springer, Heidelberg (1999)

    CrossRef  Google Scholar 

  23. Ford, B.: Parsing Expression Grammars: A Recognition-Based Syntactic Foundation. In: Principles of Programming Languages, POPL 2004, pp. 111–122 (2004)

    Google Scholar 

  24. Parr, T., Harwell, S., Fisher, K.: Adaptive LL(*) Parsing: The Power of Dynamic Analysis. In: Object Oriented Programming Systems Languages and Applications, OOPSLA 2014, pp. 579–598. ACM (2014)

    Google Scholar 

  25. Aho, A.V., Johnson, S.C., Ullman, J.D.: Deterministic Parsing of Ambiguous Grammars. In: Principles of Programming Languages, POPL 1973, pp. 1–21 (1973)

    Google Scholar 

  26. Visser, E.: Syntax Definition for Language Prototyping. PhD thesis, University of Amsterdam (1997)

    Google Scholar 

  27. Economopoulos, G., Klint, P., Vinju, J.: Faster Scannerless GLR Parsing. In: de Moor, O., Schwartzbach, M.I. (eds.) CC 2009. LNCS, vol. 5501, pp. 126–141. Springer, Heidelberg (2009)

    CrossRef  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Ali Afroozeh .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and Permissions

Copyright information

© 2015 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Afroozeh, A., Izmaylova, A. (2015). Faster, Practical GLL Parsing. In: Franke, B. (eds) Compiler Construction. CC 2015. Lecture Notes in Computer Science(), vol 9031. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-46663-6_5

Download citation

  • DOI: https://doi.org/10.1007/978-3-662-46663-6_5

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-662-46662-9

  • Online ISBN: 978-3-662-46663-6

  • eBook Packages: Computer ScienceComputer Science (R0)