Abstract
We propose a new computational model, the scaffolding automaton, which exactly characterises the computational power of parsing expression grammars (PEGs). Using this characterisation we show that:
-
PEGs have unexpected power and semantics. We present several PEGs with surprising behaviour, and languages which, unexpectedly, have PEGs, including a PEG for the language of palindromes whose length is a power of two.
-
PEGs are computationally “universal”, in the following sense: take any computable function \(f:\{0, 1\}^*\rightarrow \{0, 1\}^*\); then there exists a computable function \(g: \{0, 1\}^*\rightarrow {\mathbb {N}}\) such that \(\{ f(x) \#^{g(x)} x \mid x \in \{0, 1\}^*\}\) has a PEG.
-
There can be no pumping lemma for PEGs. There is no total computable function A with the following property: for every well-formed PEG G, there exists \(n_0\) such that for every string \(x \in {\mathcal {L}}(G)\) of size \(|x| \ge n_0\), the output \(y = A(G, x)\) is in \({\mathcal {L}}(G)\) and has \(|y| > |x|\).
-
PEGs are strongly non real-time for Turing machines. There exists a language with a PEG, such that neither it nor its reverse can be recognised by any multi-tape online Turing machine which is allowed to do only \(o(n/\log n)\) steps after reading each input symbol.
Bruno Loff is the recipient of FCT postdoc grant number SFRH/BPD/116010/2016. This work is partially funded by the ERDF through the COMPETE 2020 Programme within project POCI-01-0145-FEDER-006961, and by National Funds through the FCT as part of project UID/EEA/50014/2013. This work was partially supported by CMUP (UID/MAT/00144/2013), FCT (Portugal), FEDER and PT2020. We thank M. Kutrib and M. Holzer for the fruitful discussions on this subject.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
We here omit various references due to space constraints. See Ford’s webpage [6] for an extensive bibliography of work around PEGs.
- 2.
For example, the relatively simple grammar for the \(a^n b^n c^n\) language which appears in Ford’s original paper [9], has a (fixable) bug, which eluded discovery for over a decade (including to us, when we read Ford’s paper) until the bug was pointed out by a recent paper of Garnock-Jones et al. [10].
References
Aho, A.V., Ullman, J.D.: The Theory of Parsing, Translation, and Compiling, vol. 1. Prentice-Hall, Upper Saddle River (1972)
Amarilli, A., Jeanmougin, M.: A proof of the pumping lemma for context-free languages through pushdown automata arXiv:1207.2819 (2012)
Bar-Hillel, Y., Perles, M., Shamir, E.: On formal properties of simple phrase structure grammars. In: Bar-Hillel, Y. (ed.) Language and Information: Selected Essays on their Theory and Application. Series in Logic, pp. 116–150. Addison-Wesley (1964)
Birman, A.: The TMG recognition schema. Ph.D. thesis, Princeton (1970)
Birman, A., Ullman, J.D.: Parsing algorithms with backtrack. In: 11th Annual Symposium on Switching and Automata Theory, pp. 153–174. IEEE (1970)
Ford, B.: The packrat parsing and parsing expression grammars page. http://bford.info/packrat/
Ford, B.: Packrat parsing: a practical linear-time algorithm with backtracking. Massachusetts Institute of Technology (2002)
Ford, B.: Packrat parsing: simple, powerful, lazy, linear time, functional pearl. In: Wand, M., Jones, S.L.P. (eds.) (ICFP 2002), pp. 36–47. ACM (2002)
Ford, B.: Parsing expression grammars: a recognition-based syntactic foundation. In: ACM SIGPLAN Notices, vol. 39, pp. 111–122. ACM (2004)
Garnock-Jones, T., Eslamimehr, M., Warth, A.: Recognising and generating terms using derivatives of parsing expression grammars. CoRR abs/1801.10490 (2018)
Greibach, S.A.: The hardest context-free language. SIAM J. Comput. 2(4), 304–310 (1973)
Hartmanis, J., Stearns, R.E.: On the computational complexity of algorithms. Trans. Am. Math. Soc. 117, 285–306 (1965)
Hayashi, T.: On derivation trees of indexed grammars: an extension of the uvwxy-theorem. Publ. Res. Inst. Math. Sci. Kyoto Univ. 9, 61–92 (1973)
Hopcroft, J.E., Motwani, R., Ullman, J.D.: Introduction to automata theory, languages, and computation. ACM SIGACT News 32(1), 60–65 (2001)
Li, M., Vitányi, P.: A new approach to formal language theory by Kolmogorov complexity. SIAM J. Comput. 24(2), 398–410 (1995)
Sipser, M.: Introduction to the Theory of Computation, 3rd edn. Cengage Learning, Boston (2012)
Yu, S.: A pumping lemma for deterministic context-free languages. Inf. Process. Lett. 31(1), 47–51 (1989)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer Nature Switzerland AG
About this paper
Cite this paper
Loff, B., Moreira, N., Reis, R. (2018). The Computational Power of Parsing Expression Grammars. In: Hoshi, M., Seki, S. (eds) Developments in Language Theory. DLT 2018. Lecture Notes in Computer Science(), vol 11088. Springer, Cham. https://doi.org/10.1007/978-3-319-98654-8_40
Download citation
DOI: https://doi.org/10.1007/978-3-319-98654-8_40
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-98653-1
Online ISBN: 978-3-319-98654-8
eBook Packages: Computer ScienceComputer Science (R0)