Compiler Construction

In the compiler literature, parsing algorithms for context-free grammars are presented using string rewriting systems or abstract machines such as pushdown automata. Unfortunately, the resulting descriptions can be baroque, and even a basic understanding of some parsing algorithms, such as Earley’s algorithm for general context-free grammars, can be elusive. In this paper, we present a graphical representation of context-free grammars called the Grammar Flow Graph (GFG) that permits parsing problems to be phrased as path problems in graphs; intuitively, the GFG plays the same role for context-free grammars that nondeterministic finite-state automata play for regular grammars. We show that the GFG permits an elementary treatment of Earley’s algorithm that is much easier to understand than previous descriptions of this algorithm. In addition, look-ahead computation can be expressed as a simple inter-procedural dataflow analysis problem, providing an unexpected link between front-end and back-end technologies in compilers. These results suggest that the GFG can be a new foundation for the study of context-free grammars.

[1]  Sorin Lerner,et al.  Equality-Based Translation Validator for LLVM , 2011, CAV.

[2]  Xavier Leroy,et al.  Verified validation of lazy code motion , 2009, PLDI '09.

[3]  Mark N. Wegman,et al.  Constant propagation with conditional branches , 1985, POPL.

[4]  Xuejun Yang,et al.  Finding and understanding bugs in C compilers , 2011, PLDI '11.

[5]  Elsa L. Gunter,et al.  A Framework for Formal Verification of Compiler Optimizations , 2010, ITP.

[6]  Robert E. Tarjan,et al.  A fast algorithm for finding dominators in a flowgraph , 1979, TOPL.

[7]  Milo M. K. Martin,et al.  Formalizing the LLVM intermediate representation for verified program transformations , 2012, POPL '12.

[8]  J. Gregory Morrisett,et al.  Evaluating value-graph translation validation for LLVM , 2011, PLDI '11.

[9]  Keith D. Cooper,et al.  Value Numbering , 1997, Softw. Pract. Exp..

[10]  Ramana Kumar,et al.  CakeML: a verified implementation of ML , 2014, POPL.

[11]  Amir Pnueli,et al.  Translation Validation , 1998, TACAS.

[12]  Xavier Leroy,et al.  A Formally Verified Compiler Back-end , 2009, Journal of Automated Reasoning.

[13]  Adam Chlipala,et al.  A verified compiler for an impure functional language , 2010, POPL '10.

[14]  Santosh Nagarakatte,et al.  Formal verification of SSA-based optimizations for LLVM , 2013, PLDI.

[15]  Gilles Barthe,et al.  Formal Verification of an SSA-Based Middle-End for CompCert , 2014, TOPL.

[16]  Xavier Leroy,et al.  Validating Register Allocation and Spilling , 2010, CC.

[17]  Xavier Leroy,et al.  A simple, verified validator for software pipelining , 2010, POPL '10.

[18]  Sabine Glesner,et al.  Optimizing Code Generation from SSA Form: A Comparison Between Two Formal Correctness Proofs in Isabelle/HOL , 2005, COCV@ETAPS.

[19]  M. Wegman,et al.  Global value numbers and redundant computations , 1988, POPL '88.

[20]  Benoît Dupont de Dinechin,et al.  Revisiting Out-of-SSA Translation for Correctness, Code Quality and Efficiency , 2009, 2009 International Symposium on Code Generation and Optimization.