Advertisement

Complexity of Extended vs. Classic LR Parsers

  • Angelo Borsotti
  • Luca Breveglieri
  • Stefano Crespi Reghizzi
  • Angelo Morzenti
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8614)

Abstract

For the deterministic context-free languages, we compare the space and time complexity of their LR (1) parsers, constructed in two different ways: the classic method by Knuth [7] for BNF grammars, and the recent one by the authors [2], which directly builds the parser from EBNF grammars represented as transition networks. For the EBNF grammars, the classic Knuth’s method is indirect as it needs to convert them to BNF. We describe two parametric families of formal languages indexed by the number of stars, which exhibit a linear growth of the parser size (number of states) in passing from the classic to our novel direct methods. Experimental measurements of the number of parser states and of the parsing speed for two real languages (Java and JSON) confirm the advantage of the new direct parser model for EBNF grammars.

Keywords

Extended BNF grammar EBNF LR (1) ELR (1) transition network TN shift-reduce bottom-up parser parsing performance 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Aho, A., Lam, M., Sethi, R., Ullman, J.: Compilers: principles, techniques and tools. Prentice-Hall, Englewood Cliffs (2006)Google Scholar
  2. 2.
    Breveglieri, L., Crespi Reghizzi, S., Morzenti, A.: Shift-reduce parsers for transition networks. In: Dediu, A.-H., Martín-Vide, C., Sierra-Rodríguez, J.-L., Truthe, B. (eds.) LATA 2014. LNCS, vol. 8370, pp. 222–235. Springer, Heidelberg (2014)CrossRefGoogle Scholar
  3. 3.
    Conway, M.E.: Design of a separable transition-diagram compiler. Comm. ACM 6(7), 396–408 (1963)CrossRefzbMATHGoogle Scholar
  4. 4.
    Crespi Reghizzi, S., Breveglieri, L., Morzenti, A.: Formal languages and compilation, 2nd edn. Springer, London (2013)CrossRefzbMATHGoogle Scholar
  5. 5.
    Grune, D., Jacobs, C.: Parsing techniques: a practical guide, 2nd edn. Springer, London (2009)Google Scholar
  6. 6.
    Hemerik, K.: Towards a taxonomy for ECFG and RRPG parsing. In: Dediu, A.H., Ionescu, A.M., Martín-Vide, C. (eds.) LATA 2009. LNCS, vol. 5457, pp. 410–421. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  7. 7.
    Knuth, D.E.: On the translation of languages from left to right. Information and Control 8, 607–639 (1965)CrossRefMathSciNetGoogle Scholar
  8. 8.
    Pager, D.: A practical general method for constructing LR(k) parsers. Acta Inf. 7, 249–268 (1977)CrossRefzbMATHMathSciNetGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Angelo Borsotti
    • 1
  • Luca Breveglieri
    • 1
  • Stefano Crespi Reghizzi
    • 1
  • Angelo Morzenti
    • 1
  1. 1.Politecnico di Milano, DEIBMilanoItaly

Personalised recommendations