FliPpr: A Prettier Invertible Printing System

When implementing a programming language, we often write a parser and a pretty-printer. However, manually writing both programs is not only tedious but also error-prone; it may happen that a pretty-printed result is not correctly parsed. In this paper, we propose FliPpr, which is a program transformation system that uses program inversion to produce a CFG parser from a pretty-printer. This novel approach has the advantages of fine-grained control over pretty-printing, and easy reuse of existing efficient pretty-printer and parser implementations.

[1]  Brenda S. Baker,et al.  Composition of Top-Down and Bottom-Up Tree Transductions , 1979, Inf. Control..

[2]  Philip Wadler,et al.  Deforestation: Transforming Programs to Eliminate Trees , 1988, Theoretical Computer Science.

[3]  Peter Sestoft,et al.  Non-Determinism in Functional Languages , 1992, Comput. J..

[4]  David Sands Proving the Correctness of Recursion-Based Automatic Program Transformations , 1995, TAPSOFT.

[5]  John Hughes,et al.  The Design of a Pretty-printing Library , 1995, Advanced Functional Programming.

[6]  Robert Glück,et al.  A positive supercompiler , 1996, Journal of Functional Programming.

[7]  Zoltán Fülöp,et al.  Syntax-Directed Semantics , 1998, Monographs in Theoretical Computer Science An EATCS Series.

[8]  Robert Glück,et al.  Relating Accumulative and Non-accumulative Functional Programs , 2001, RTA.

[9]  Philip Wadler,et al.  A prettier printer , 2002 .

[10]  Johan Jeuring,et al.  Polytypic data conversion programs , 2002, Sci. Comput. Program..

[11]  Philip Wadler XQuery: A Typed Functional Language for Querying XML , 2002, Advanced Functional Programming.

[12]  Oege de Moor,et al.  The Fun of Programming , 2003 .

[13]  Benjamin C. Pierce,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[14]  Claus Brabrand,et al.  Dual syntax for XML languages , 2005, Inf. Syst..

[15]  Richard A. Frost,et al.  Parser Combinators for Ambiguous Left-Recursive Grammars , 2008, PADL.

[16]  Benjamin C. Pierce,et al.  Quotient lenses , 2008, ICFP 2008.

[17]  Johan Nordlander,et al.  Positive supercompilation for a higher order call-by-value language , 2009, POPL '09.

[18]  Brian Campbell,et al.  Amortised Memory Analysis Using the Depth of Data Structures , 2009, ESOP.

[19]  Shin-Cheng Mu,et al.  A Grammar-Based Approach to Invertible Programs , 2010, ESOP.

[20]  Invertible syntax descriptions: unifying parsing and pretty printing , 2010, Haskell '10.

[21]  Naoki Kobayashi,et al.  Higher-order multi-parameter tree transducers and recursion schemes for program verification , 2010, POPL '10.

[22]  David Darais,et al.  Parsing with derivatives: a functional pearl , 2011, ICFP.

[23]  Zoltán Fülöp,et al.  Syntax-Directed Semantics: Formal Models Based on Tree Transducers , 2011 .

[24]  Patrik Jansson,et al.  Embedded parser generators , 2012 .

[25]  Jonas Duregård,et al.  Feat: functional enumeration of algebraic types , 2013, Haskell '12.