Abstract
Ford presented Parsing Expression Grammars (PEGs) as an alternative to specify rules for programming language, along with a Packrat parser, based on an idea of memoization. The idea proposed by Ford guarantees parsing of grammar written using PEGs in linear time in spite of backtracking. The primary aim of the paper is to highlight the details of PEGs followed by various challenges existing for a better understanding of the readers. From the entire overview presented, it has been observed that PEGs address the issue of undesired ambiguity in grammar for computer-oriented programming language, by not allowing any ambiguity in rules itself at the first place. However, the guarantee of linear time execution comes with a cost of large heap consumption, making it infeasible to implement for large inputs. Optimizing the resources required for memoization, may allow us to utilize the benefits offered by PEGs.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
Birman A (1970) The TMG recognition schema. PhD thesis, Princeton University, Department of Electrical Engineering, Princeton, NJ
Birman A, Ullman JD (1973) Parsing algorithms with backtrack. Inf Control 23(1):1–34
Ford B (2004) Parsing expression grammars: a recognition-based syntactic foundation. In: Proceedings of the 31st ACM SIGPLAN-SIGACT symposium on principles of programming languages (POPL ‘04). ACM, New York, NY
Ford B (2002) Packrat parsing: a practical linear-time algorithm with backtracking. Master’s thesis, Massachusetts Institute of Technology, Department of Electrical Engineering and Computer Science, Cambridge, MA
Ford B (2002) Packrat parsing: simple, powerful, lazy, linear time-functional pearl. In: Proceedings of the ACM SIGPLAN international conference on functional programming, ICFP, Pittsburgh. ACM
Medeiros S, Ierusalimschy R (2008) A parsing machine for PEGs. In: Proceedings of the 2008 symposium on dynamic languages (DLS ‘08). ACM, New York, NY
Oikawa M, Ierusalimschy R, Moura A (2010) Converting regexes to parsing expression grammars. In: Proceedings of the 14th Brazilian symposium on programming languages, SBLP, vol 10
Becket R, Somogyi Z (2008) DCGs + memoing = packrat parsing but is it worth it? In: 10th international symposium, PADL 2008, San Francisco, CA, 7–8 Jan 2008
Grimm R (2004) Practical packrat parsing. New York University technical report, Dept. of Computer Science, TR2004-854
Redziejowski RR (2009) Mouse: from parsing expressions to a practical parser. In: Concurrency specification and programming workshop
Chida N, Kuramitsu K (2017) Linear parsing expression grammars. Preprint version, Sept 2017
Dubroy P, Warth A (2017) Incremental packrat parsing. In: Proceedings of 2017 ACM SIGPLAN international conference on software language engineering (SLE’17). ACM, New York, NY
Laurent N, Mens K (2016) Parsing expression grammars made practical. Preprint version, Sept 2016
Moss A (2014) Derivatives of parsing expression grammars. arXiv preprint arXiv:1405.4841
Johnson M (1995) Memoization in top-down parsing. Comput Linguist 21
Warth A, Douglass JR, Millstein TD (2008) Packrat parsers can support left recursion. In: PEPM 8
Kuramitsu K (2015) Packrat parsing with elastic sliding window. J Inf Process 23(4)
Goswami MM, Raghuwanshi MM, Malik L (2016) Performance improvement of stack based recursive-descent parser for parsing expression grammar. Int J Latest Trends Eng Technol 6(3)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2023 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.
About this paper
Cite this paper
Mangrulkar, N.S., Singh, K.R., Raghuwanshi, M.M. (2023). Parsing Expression Grammar and Packrat Parsing—A Review. In: Joshi, A., Mahmud, M., Ragel, R.G. (eds) Information and Communication Technology for Competitive Strategies (ICTCS 2021). Lecture Notes in Networks and Systems, vol 400. Springer, Singapore. https://doi.org/10.1007/978-981-19-0095-2_36
Download citation
DOI: https://doi.org/10.1007/978-981-19-0095-2_36
Published:
Publisher Name: Springer, Singapore
Print ISBN: 978-981-19-0094-5
Online ISBN: 978-981-19-0095-2
eBook Packages: EngineeringEngineering (R0)