Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/1328408.1328424acmconferencesArticle/Chapter ViewAbstractPublication PagespepmConference Proceedingsconference-collections
research-article

Packrat parsers can support left recursion

Published: 07 January 2008 Publication History

Abstract

Packrat parsing offers several advantages over other parsing techniques, such as the guarantee of linear parse times while supporting backtracking and unlimited look-ahead. Unfortunately, the limited support for left recursion in packrat parser implementations makes them difficult to use for a large class of grammars (Java's, for example). This paper presents a modification to the memoization mechanism used by packrat parser implementations that makes it possible for them to support (even indirectly or mutually) left-recursive rules. While it is possible for a packrat parser with our modification to yield super-linear parse times for some left-recursive grammars, our experimentsshow that this is not the case for typical uses of left recursion.

References

[1]
Bryan Ford. Packrat Parsing: a practical linear-time algorithm with backtracking. Master's thesis, Massachusetts Institute of Technology, September 2002.
[2]
Bryan Ford. Packrat Parsing: Simple, Powerful, Lazy, Linear Time (functional pearl). In ICFP '02: Proceedings of the seventh ACM SIGPLAN International Conference on Functional Programming, pages 36--47, New York, NY, USA, 2002. ACM Press.
[3]
Bryan Ford. Parsing Expression Grammars: a Recognition-Based Syntactic Foundation. In POPL '04: Proceedings of the 31st ACM SIGPLAN-SIGACT symposium on Principles of Programming Languages, pages 111--122, New York, NY, USA, 2004. ACM Press.
[4]
Richard A. Frost and Rahmatullah Hafiz. A new top-down parsing algorithm to accommodate ambiguity and left recursion in polynomial time. SIGPLAN Notices, 41(5):46--54, 2006.
[5]
James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification, Third Edition. Addison-Wesley, 2005.
[6]
Robert Grimm. Better Extensibility Through Modular Syntax. In PLDI '06: Proceedings of the 2006 ACM SIGPLAN conference on Programming Language Design and Implementation, pages 38--51, New York, NY, USA, 2006. ACM Press.
[7]
Mark Johnson. Memoization in top-down parsing. Computational Linguistics, 21(3):405--417, 1995.
[8]
Roman Redziejowski. Parsing Expression Grammar as a primitive recursive-descent parser with backtracking. In G. Lindemann and H. Schlingloff, editors, Proceedings of the CS&P'2006 Workshop, volume 3 of Informatik-Bericht Nr. 206, pages 304--315. Humboldt-Universitäät zu Berlin, 2006. To appear in Fundamenta Informaticae.
[9]
Eric Van Wyk and August Schwerdfeger. Context-Aware Scanning for Parsing Extensible Languages. In Intl. Conf. on Generative Programming and Component Engineering, GPCE 2007. ACM Press, October 2007.
[10]
Eelco Visser. Scannerless Generalized-LR Parsing. Technical Report P9707, Programming Research Group, University of Amsterdam.
[11]
Alessandro Warth and Ian Piumarta. OMeta: an Object-Oriented Language for Pattern-Matching. In OOPSLA '07: Companion to the 22nd ACM SIGPLAN conference on Object-Oriented Programming Systems, Languages, and Applications, New York, NY, USA, 2007. ACM Press.

Cited By

View all
  • (2023)Ordered Context-Free Grammars RevisitedElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.388.13388(140-153)Online publication date: 15-Sep-2023
  • (2023)Type-based Termination Analysis for Parsing Expression GrammarsProceedings of the 38th ACM/SIGAPP Symposium on Applied Computing10.1145/3555776.3577620(1372-1379)Online publication date: 27-Mar-2023
  • (2023)Stack and Queue Based Parser Approach for Parsing Expression Grammar2023 11th International Conference on Emerging Trends in Engineering & Technology - Signal and Information Processing (ICETET - SIP)10.1109/ICETET-SIP58143.2023.10151539(1-6)Online publication date: 28-Apr-2023
  • Show More Cited By

Index Terms

  1. Packrat parsers can support left recursion

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    PEPM '08: Proceedings of the 2008 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulation
    January 2008
    214 pages
    ISBN:9781595939777
    DOI:10.1145/1328408
    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]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 07 January 2008

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. left recursion
    2. packrat parsing

    Qualifiers

    • Research-article

    Conference

    PEPM08
    PEPM08: Partial Evaluation and Program Manipulation
    January 7 - 8, 2008
    California, San Francisco, USA

    Acceptance Rates

    Overall Acceptance Rate 66 of 120 submissions, 55%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)33
    • Downloads (Last 6 weeks)3
    Reflects downloads up to 22 Feb 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2023)Ordered Context-Free Grammars RevisitedElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.388.13388(140-153)Online publication date: 15-Sep-2023
    • (2023)Type-based Termination Analysis for Parsing Expression GrammarsProceedings of the 38th ACM/SIGAPP Symposium on Applied Computing10.1145/3555776.3577620(1372-1379)Online publication date: 27-Mar-2023
    • (2023)Stack and Queue Based Parser Approach for Parsing Expression Grammar2023 11th International Conference on Emerging Trends in Engineering & Technology - Signal and Information Processing (ICETET - SIP)10.1109/ICETET-SIP58143.2023.10151539(1-6)Online publication date: 28-Apr-2023
    • (2023)Left Recursion by Recursive AscentConcurrency, Specification and Programming10.1007/978-3-031-26651-5_2(29-46)Online publication date: 5-May-2023
    • (2022)Partial Parsing for Structured EditorsProceedings of the 15th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3567512.3567522(110-120)Online publication date: 29-Nov-2022
    • (2022)A Type-Directed Algorithm to Generate Random Well-Formed Parsing Expression GrammarsProceedings of the XXVI Brazilian Symposium on Programming Languages10.1145/3561320.3561326(8-14)Online publication date: 6-Oct-2022
    • (2022)Parsing Expression Grammar and Packrat Parsing—A ReviewInformation and Communication Technology for Competitive Strategies (ICTCS 2021)10.1007/978-981-19-0095-2_36(377-384)Online publication date: 23-Jun-2022
    • (2022)Ordered Context-Free GrammarsImplementation and Application of Automata10.1007/978-3-031-07469-1_4(53-66)Online publication date: 28-Jun-2022
    • (2021)Parglare: A LR/GLR parser for PythonScience of Computer Programming10.1016/j.scico.2021.102734(102734)Online publication date: Oct-2021
    • (2020)JISETProceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering10.1145/3324884.3416632(647-658)Online publication date: 21-Dec-2020
    • Show More Cited By

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Figures

    Tables

    Media

    Share

    Share

    Share this Publication link

    Share on social media