skip to main content
10.1145/3555776.3577620acmconferencesArticle/Chapter ViewAbstractPublication PagessacConference Proceedingsconference-collections
research-article

Type-based Termination Analysis for Parsing Expression Grammars

Published:07 June 2023Publication History

ABSTRACT

Parsing expressions grammars (PEGs) are a recognition-based formalism for language specification, which has been the subject of several research works. A PEG that succeeds or rejects every input string is said to be complete. However, checking if an arbitrary PEG is complete is an undecidable problem. In this work we propose a sound type-based termination analysis for PEGs as a type inference algorithm.

References

  1. Michael D. Adams. 2013. Principled parsing for indentation-sensitive languages: revisiting landin's offside rule. In Proceedings of the 40th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages (Rome, Italy) (POPL '13). ACM, New York, NY, USA, 511--522. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Clark Barrett, Aaron Stump, and Cesare Tinelli. 2010. The SMT-LIB Standard: Version 2.0. In Proceedings of the 8th International Workshop on Satisfiability Modulo Theories (Edinburgh, UK), A. Gupta and D. Kroening (Eds.).Google ScholarGoogle Scholar
  3. Jean-Philippe Bernardy and Patrik Jansson. 2016. Certified Context-Free Parsing: A formalisation of Valiant's Algorithm in Agda. Logical Methods in Computer Science 12 (2016). Issue 2. Google ScholarGoogle ScholarCross RefCross Ref
  4. Clement Blaudeau and Natarajan Shankar. 2020. A Verified Packrat Parser Interpreter for Parsing Expression Grammars. In Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (New Orleans, LA, USA) (CPP 2020). Association for Computing Machinery, New York, NY, USA, 3--17. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Janusz A. Brzozowski. 1964. Derivatives of Regular Expressions. J. ACM 11, 4 (oct 1964), 481--494. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Leonardo Mendonça de Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. In Tools and Algorithms for the Construction and Analysis of Systems, 14th International Conference, TACAS 2008, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2008, Budapest, Hungary, March 29-April 6, 2008. Proceedings (Lecture Notes in Computer Science, Vol. 4963), C. R. Ramakrishnan and Jakob Rehof (Eds.). Springer, 337--340. Google ScholarGoogle ScholarCross RefCross Ref
  7. Thales Antônio Delfino and Rodrigo Geraldo Ribeiro. 2018. Towards certified virtual machine-based regular expression parsing. In Proceedings of the XXII Brazilian Symposium on Programming Languages, SBLP 2018, Sao Carlos, Brazil, September 20-21, 2018, Carlos Camarão and Martin Sulzmann (Eds.). ACM, 67--74. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Romain Edelmann, Jad Hamza, and Viktor Kunčak. 2020. Zippy LL(1) Parsing with Derivatives. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (London, UK) (PLDI 2020). Association for Computing Machinery, New York, NY, USA, 1036--1051. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, Shriram Krishnamurthi, Eli Barzilay, Jay A. McCarthy, and Sam Tobin-Hochstadt. 2018. A programmable programming language. Commun. ACM 61, 3 (2018), 62--71. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Denis Firsov and Tarmo Uustalu. 2013. Certified Parsing of Regular Languages. In Certified Programs and Proofs - Third International Conference, CPP 2013, Melbourne, VIC, Australia, December 11-13, 2013, Proceedings (Lecture Notes in Computer Science, Vol. 8307), Georges Gonthier and Michael Norrish (Eds.). Springer, 98--113. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Denis Firsov and Tarmo Uustalu. 2014. Certified CYK parsing of context-free languages. J. Log. Algebraic Methods Program. 83, 5-6 (2014), 459--468. Google ScholarGoogle ScholarCross RefCross Ref
  12. Bryan Ford. 2004. Parsing Expression Grammars: A Recognition-Based Syntactic Foundation. In Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Venice, Italy) (POPL '04). Association for Computing Machinery, New York, NY, USA, 111--122. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Dick Grune and Ceriel J.H. Jacobs. 1990. Parsing Techniques - A Practical Guide. Ellis Horwood, Chichester, England. 300+ pages. http://www.cs.vu.nl/~dick/PTAPG.html PDF online free.Google ScholarGoogle Scholar
  14. Grzegorz Herman. 2020. Faster General Parsing through Context-Free Memoization. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (London, UK) (PLDI 2020). Association for Computing Machinery, New York, NY, USA, 1022--1035. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Trevor Jim, Yitzhak Mandelbaum, and David Walker. 2010. Semantics and Algorithms for Data-dependent Grammars. In Proceedings of the 37th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Madrid, Spain) (POPL'10). ACM, New York, NY, USA, 417--430. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Adam Koprowski and Henri Binsztok. 2011. TRX: A Formally Verified Parser Interpreter. Log. Methods Comput. Sci. 7, 2 (2011). Google ScholarGoogle ScholarCross RefCross Ref
  17. Neelakantan R. Krishnaswami and Jeremy Yallop. 2019. A Typed, Algebraic Approach to Parsing. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (Phoenix, AZ, USA) (PLDI 2019). Association for Computing Machinery, New York, NY, USA, 379--393. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Sam Lasser, Chris Casinghino, Kathleen Fisher, and Cody Roux. 2021. CoStar: A Verified ALL(*) Parser. Association for Computing Machinery, New York, NY, USA, 420--434. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Raul Lopes, Rodrigo Geraldo Ribeiro, and Carlos Camarão. 2016. Certified Derivative-Based Parsing of Regular Expressions. In Programming Languages - 20th Brazilian Symposium, SBLP 2016, Maringá, Brazil, September 22-23, 2016, Proceedings (Lecture Notes in Computer Science, Vol. 9889), Fernando Castor and Yu David Liu (Eds.). Springer, 95--109. Google ScholarGoogle ScholarCross RefCross Ref
  20. Fabio Mascarenhas, Sérgio Medeiros, and Roberto Ierusalimschy. 2014. On the relation between context-free grammars and parsing expression grammars. Sci. Comput. Program. 89 (2014), 235--250. Google ScholarGoogle ScholarCross RefCross Ref
  21. Sérgio Medeiros, Fabio Mascarenhas, and Roberto Ierusalimschy. 2014. Left recursion in Parsing Expression Grammars. Sci. Comput. Program. 96 (2014), 177--190. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Lasse Nielsen and Fritz Henglein. 2011. Bit-coded Regular Expression Parsing. In Language and Automata Theory and Applications - 5th International Conference, LATA 2011, Tarragona, Spain, May 26-31, 2011. Proceedings (Lecture Notes in Computer Science, Vol. 6638), Adrian-Horia Dediu, Shunsuke Inenaga, and Carlos Martín-Vide (Eds.). Springer, 402--413. Google ScholarGoogle ScholarCross RefCross Ref
  23. Terence Parr, Sam Harwell, and Kathleen Fisher. 2014. Adaptive LL(*) Parsing: The Power of Dynamic Analysis. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (Portland, Oregon, USA) (OOPSLA'14). ACM, New York, NY, USA, 579--598. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. François Pottier and Didier Rémy. 2005. The Essence of ML Type Inference. In Advanced Topics in Types and Programming Languages, Benjamin C. Pierce (Ed.). MIT Press, Chapter 10, 389--489.Google ScholarGoogle Scholar
  25. Leonardo V. S. Reis, Roberto S. Bigonha, Vladimir Oliveira Di Iorio, and Luis Eduardo Souza Amorim. 2014. The formalization and implementation of Adaptable Parsing Expression Grammars. Science of Computer Programming 96, Part 2 (2014), 191--210.Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Rodrigo Ribeiro and André Du Bois. 2017. Certified Bit-Coded Regular Expression Parsing. In Proceedings of the 21st Brazilian Symposium on Programming Languages (Fortaleza, CE, Brazil) (SBLP 2017). Association for Computing Machinery, New York, NY, USA, Article 4, 8 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Rodrigo Ribeiro, Leonardo V. S. Reis, Samuel Feitosa, and Elton M. Cardoso. 2019. Towards Typed Semantics for Parsing Expression Grammars. In Proceedings of the XXIII Brazilian Symposium on Programming Languages (Salvador, Brazil) (SBLP 2019). Association for Computing Machinery, New York, NY, USA, 70--77. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Tom Ridge. 2011. Simple, Functional, Sound and Complete Parsing for All Context-Free Grammars. In Certified Programs and Proofs, Jean-Pierre Jouannaud and Zhong Shao (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 103--118.Google ScholarGoogle Scholar
  29. Elton M. Cardoso Rodrigo G. Ribeiro. 2022. typed-peg Library - online repository. https://github.com/lives-group/typed-peg.Google ScholarGoogle Scholar
  30. Martin Sulzmann and Peter Thiemann. 2017. A Computational Interpretation of Context-Free Expressions. In Programming Languages and Systems - 15th Asian Symposium, APLAS 2017, Suzhou, China, November 27-29, 2017, Proceedings (Lecture Notes in Computer Science, Vol. 10695), Bor-Yuh Evan Chang (Ed.). Springer, 387--405. Google ScholarGoogle ScholarCross RefCross Ref
  31. Alessandro Warth, James R. Douglass, and Todd Millstein. 2008. Packrat Parsers Can Support Left Recursion. In Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation (San Francisco, California, USA) (PEPM '08). Association for Computing Machinery, New York, NY, USA, 103--110. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Type-based Termination Analysis for Parsing Expression Grammars

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in
        • Published in

          cover image ACM Conferences
          SAC '23: Proceedings of the 38th ACM/SIGAPP Symposium on Applied Computing
          March 2023
          1932 pages
          ISBN:9781450395175
          DOI:10.1145/3555776

          Copyright © 2023 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 7 June 2023

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article

          Acceptance Rates

          Overall Acceptance Rate1,650of6,669submissions,25%

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader