Abstract
An LR(1) parser is a finite-state automaton, equipped with a stack, which uses a combination of its current state and one lookahead symbol in order to determine which action to perform next. We present a validator which, when applied to a context-free grammar \(\mathcal G\) and an automaton \(\mathcal A\), checks that \(\mathcal A\) and \(\mathcal G\) agree. Validating the parser provides the correctness guarantees required by verified compilers and other high-assurance software that involves parsing. The validation process is independent of which technique was used to construct \(\mathcal A\). The validator is implemented and proved correct using the Coq proof assistant. As an application, we build a formally-verified parser for the C99 language.
Chapter PDF
Similar content being viewed by others
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
Leroy, X.: Formal verification of a realistic compiler. Communications of the ACM 52, 107–115 (2009)
Barthwal, A., Norrish, M.: Verified, Executable Parsing. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 160–174. Springer, Heidelberg (2009)
Barthwal, A.: A formalisation of the theory of context-free languages in higher order logic. PhD thesis, Australian National University (December 2010)
DeRemer, F.L.: Simple LR(k) grammars. Communications of the ACM 14(7), 453–460 (1971)
Anderson, T., Eve, J., Horning, J.J.: Efficient LR(1) parsers. Acta Informatica 2, 12–39 (1973)
Pager, D.: A practical general method for constructing LR(k) parsers. Acta Informatica 7, 249–268 (1977)
Knuth, D.E.: On the translation of languages from left to right. Information & Control 8, 607–639 (1965)
Pottier, F., Régis-Gianas, Y.: The Menhir parser generator, http://gallium.inria.fr/~fpottier/menhir/
Jourdan, J.H., Pottier, F., Leroy, X.: Coq code for validating LR(1) parsers, http://www.eleves.ens.fr/home/jjourdan/parserValidator.tgz
Filliâtre, J.-C., Letouzey, P.: Functors for Proofs and Programs. In: Schmidt, D. (ed.) ESOP 2004. LNCS, vol. 2986, pp. 370–384. Springer, Heidelberg (2004)
ISO/IEC: Programming languages — C (2007) International standard ISO/IEC 9899:TC3
Padioleau, Y.: Parsing C/C++ Code without Pre-processing. In: de Moor, O., Schwartzbach, M.I. (eds.) CC 2009. LNCS, vol. 5501, pp. 109–125. Springer, Heidelberg (2009)
Pottier, F., Régis-Gianas, Y.: Towards efficient, typed LR parsers. Electronic Notes in Theoretical Computer Science 148(2), 155–180 (2006)
Ford, B.: Packrat parsing: simple, powerful, lazy, linear time. In: ACM International Conference on Functional Programming (ICFP), pp. 36–47 (October 2002)
Ford, B.: Parsing expression grammars: a recognition-based syntactic foundation. In: ACM Symposium on Principles of Programming Languages (POPL), pp. 111–122 (January 2004)
Warth, A., Douglass, J.R., Millstein, T.D.: Packrat parsers can support left recursion. In: ACM Workshop on Evaluation and Semantics-Based Program Manipulation (PEPM), pp. 103–110 (January 2008)
Koprowski, A., Binsztok, H.: TRX: A formally verified parser interpreter. Logical Methods in Computer Science 7 (2011)
Wisnesky, R., Malecha, G., Morrisett, G.: Certified web services in Ynot. In: Workshop on Automated Specification and Verification of Web Systems (July 2009)
Samet, H.: Automatically Proving the Correctness of Translations Involving Optimized Code. PhD thesis, Stanford University (1975)
Pnueli, A., Siegel, M., Singerman, E.: Translation Validation. In: Steffen, B. (ed.) TACAS 1998. LNCS, vol. 1384, pp. 151–166. Springer, Heidelberg (1998)
Necula, G.C.: Translation validation for an optimizing compiler. In: ACM Conference on Programming Language Design and Implementation (PLDI), pp. 83–95. ACM Press (2000)
Tristan, J.B., Leroy, X.: A simple, verified validator for software pipelining. In: ACM Symposium on Principles of Programming Languages (POPL), pp. 83–92. ACM Press (2010)
Klein, G., Nipkow, T.: A machine-checked model for a Java-like language, virtual machine and compiler. ACM Transactions on Programming Languages and Systems 28, 619–695 (2006)
Aho, A.V., Ullman, J.D.: The theory of parsing, translation, and compiling. Prentice-Hall (1972)
Sozeau, M.: Program-ing finger trees in Coq. In: ACM International Conference on Functional Programming (ICFP), pp. 13–24 (September 2007)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Jourdan, JH., Pottier, F., Leroy, X. (2012). Validating LR(1) Parsers. In: Seidl, H. (eds) Programming Languages and Systems. ESOP 2012. Lecture Notes in Computer Science, vol 7211. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-28869-2_20
Download citation
DOI: https://doi.org/10.1007/978-3-642-28869-2_20
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-28868-5
Online ISBN: 978-3-642-28869-2
eBook Packages: Computer ScienceComputer Science (R0)