Skip to main content
Log in

Generalized LR Parsing Algorithm for Grammars with One-Sided Contexts

  • Published:
Theory of Computing Systems Aims and scope Submit manuscript

    We’re sorry, something doesn't seem to be working properly.

    Please try refreshing the page. If that doesn't work, please contact support so we can address the problem.

Abstract

The Generalized LR parsing algorithm for context-free grammars is notable for having a decent worst-case running time (cubic in the length of the input string, if implemented efficiently), as well as much better performance on “good” grammars. This paper extends the Generalized LR algorithm to the case of “grammars with left contexts” (M. Barash, A. Okhotin, “An extension of context-free grammars with one-sided context specifications”, Inform. Comput., 2014), which augment the context-free grammars with special operators for referring to the left context of the current substring, along with a conjunction operator (as in conjunctive grammars) for combining syntactical conditions. All usual components of the LR algorithm, such as the parsing table, shift and reduce actions, etc., are extended to handle the context operators. The resulting algorithm is applicable to any grammar with left contexts and has the same worst-case cubic-time performance as in the case of context-free grammars.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5

Similar content being viewed by others

References

  1. Aizikowitz, T., Kaminski, M.: LR(0) Conjunctive grammars and deterministic synchronized alternating pushdown automata, Computer Science in Russia (CSR 2011, St. Petersburg, Russia). LNCS 6651, 345–358 (2011)

    MATH  Google Scholar 

  2. Aycock, J., Horspool, R.N., Janoušek, J., Melichar, B.: Even faster generalized LR parsing. Acta Informatica 37(9), 633–651 (2001)

    Article  MathSciNet  MATH  Google Scholar 

  3. Barash, M.: Programming language specification by a grammar with contexts. NCMA 2013 (Umeå, Sweden, 13–14, August 2013, 51–67

  4. Barash, M., Okhotin, A.: An extension of context-free grammars with one-sided context specifications. Inf. Comput. 237, 268–293 (2014)

    Article  MathSciNet  MATH  Google Scholar 

  5. Barash, M., Okhotin, A.: Two-sided context specifications in formal grammars. Theor. Comput. Sci. 591, 134–153 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  6. Barash, M., Okhotin, A.: Linear grammars with one-sided contexts and their automaton representation. RAIRO Informatique Théorique et Applications 49(2), 153–178 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  7. Clark, A., Eyraud, R., Habrard, A.: Using contextual representations to efficiently learn context-free languages. J. Mach. Learn. Res. 11, 2707–2744 (2010)

    MathSciNet  MATH  Google Scholar 

  8. Economopoulos, G., Klint, P., Vinju, J.: Faster scannerless GLR parsing. Compiler Construction (CC 2009, York, United Kingdom, March 22–29, 2009) LNCS 5501, 126–141

  9. Kallmeyer, L., Maier, W.: LR Parsing for LCFRS. Human Language Technologies (NAACL HLT 2015, Denver, Colorado, USA, 31 May–5 June 2015), 1250–1255

  10. Kipps, J.R.: GLR parsing in time \(\mathcal {O}(n^{3})\). In: Tomita, M. (ed.) Generalized LR Parsing, Kluwer, pp 43–59 (1991)

  11. Knuth, D.E.: On the translation of languages from left to right. Inf. Control. 8, 607–639 (1965)

    Article  MathSciNet  MATH  Google Scholar 

  12. Kowalski, R.: Logic for Problem Solving. North-Holland, Amsterdam (1979)

    MATH  Google Scholar 

  13. Lang, B.: Deterministic techniques for efficient non-deterministic parsers. Automata, Languages and Programming (ICALP 1974, Saarbrücken, Germany, July 29–August 2, 1974), LNCS 14, 255– 269

  14. Nederhof, M.-J.: An alternative LR algorithm for TAGs. 36th Annual Meeting of the Association for Computational Linguistics (COLING-ACL’98, Montréal, Canada, 10–14 August 1998), 946–952

  15. Okhotin, A.: Conjunctive grammars. Journal of Automata, Languages and Combinatorics 6(4), 519–535 (2001)

    MathSciNet  MATH  Google Scholar 

  16. Okhotin, A.: LR Parsing for conjunctive grammars. Grammars 5, 81–124 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  17. Okhotin, A.: Generalized LR parsing algorithm for Boolean grammars. Int. J. Found. Comput. Sci. 17(3), 629–664 (2006)

    Article  MathSciNet  MATH  Google Scholar 

  18. Okhotin, A.: Conjunctive and Boolean grammars: the true general case of the context-free grammars. Computer Science Review 9, 27–59 (2013)

    Article  MATH  Google Scholar 

  19. Okhotin, A.: Parsing by matrix multiplication generalized to Boolean grammars. Theor. Comput. Sci. 516, 101–120 (2014)

    Article  MathSciNet  MATH  Google Scholar 

  20. Okhotin, A.: Improved normal form for grammars with one-sided contexts. Theor. Comput. Sci. 588, 52–72 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  21. Okhotin, A.: Input-driven languages are linear conjunctive. Theor. Comput. Sci. 618, 52–71 (2016)

    Article  MathSciNet  MATH  Google Scholar 

  22. Pereira, F.C.N., Warren, D.H.D.: Parsing as deduction. 21st Annual Meeting of the Association for Computational Linguistics (ACL 1983, Cambridge, Mass., USA, 15–17 June 1983), 137–144

  23. Prolo, C.A.: An efficient LR parser generator for tree-adjoining grammars. In: Bunt, H., Caroll, J., Satta, G. (eds.) New Developments in Parsing Technology, pp 125–155 (2005)

  24. Rabkin, M.: Recognizing two-sided contexts in cubic time. Computer Science—Theory and Applications (CSR 2014, Moscow, Russia, 6–12, June 2014), LNCS 8476, 14–324

  25. Rounds, W.C.: LFP: A logic for linguistic descriptions and an analysis of its complexity. Computational Linguistics 14(4), 1–9 (1988)

    Google Scholar 

  26. Scott, E., Johnstone, A.: Right nulled GLR parsers. ACM Trans. Program. Lang. Syst. 28(4), 577–618 (2006)

    Article  MATH  Google Scholar 

  27. Tomita, M.: Efficient Parsing for Natural Language. Kluwer (1986)

  28. Tomita, M.: An efficient augmented context-free parsing algorithm. Computational Linguistics 13(1), 31–46 (1987)

    Google Scholar 

  29. Yoshinaka, R.: Learning conjunctive grammars and contextual binary feature grammars. Language and Automata Theory and Applications (LATA 2015, Nice, France, 2–6, March 2015), LNCS 8977, 623–635

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Alexander Okhotin.

Additional information

A preliminary version of this paper was presented at the 10th International Computer Science Symposium in Russia (CSR 2015) held in Listvyanka (Lake Baikal), Russia, on July 13–17, 2015, and its extended abstract appeared in the conference proceedings. Research supported by a grant from the Finnish Cultural Foundation.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Barash, M., Okhotin, A. Generalized LR Parsing Algorithm for Grammars with One-Sided Contexts. Theory Comput Syst 61, 581–605 (2017). https://doi.org/10.1007/s00224-016-9683-3

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00224-016-9683-3

Keywords

Navigation