[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
research-article

Invertible syntax descriptions: unifying parsing and pretty printing

Published: 30 September 2010 Publication History

Abstract

Parsers and pretty-printers for a language are often quite similar, yet both are typically implemented separately, leading to redundancy and potential inconsistency. We propose a new interface of syntactic descriptions, with which both parser and pretty-printer can be described as a single program. Whether a syntactic description is used as a parser or as a pretty-printer is determined by the implementation of the interface. Syntactic descriptions enable programmers to describe the connection between concrete and abstract syntax once and for all, and use these descriptions for parsing or pretty-printing as needed. We also discuss the generalization of our programming technique towards an algebra of partial isomorphisms.

Supplementary Material

JPG File (haskell-0910.jpg)
MOV File (haskell-0910.mov)

References

[1]
}}Sergei Abramov and Robert Glück. Principles of inverse computation and the universal resolving algorithm. In The essence of computation: complexity, analysis, transformation, pages 269--295. Springer LNCS 2566, New York, 2002.
[2]
}}Artem Alimarine, Sjaak Smetsers, Arjen van Weelden, Marko van Eekelen, and Rinus Plasmeijer. There and back again: arrows for invertible programming. In Proceedings of the workshop on Haskell (Haskell '05), pages 86--97, New York, 2005.
[3]
}}Kenichi Asai. On typing delimited continuations: three new solutions to the printf problem. Higher-Order and Symbolic Computation, 22(3): 275--291, September 2009.
[4]
}}Claus Brabrand, Anders Møller, and Michael I. Schwartzbach. Dual syntax for XML languages. Information Systems, 33(4-5):385--406, 2008.
[5]
}}Olivier Danvy. Functional unparsing. Journal of Functional Programming,8(6):621--625, 1998.
[6]
}}Olivier Danvy. From reduction-based to reduction-free normalization. In Advanced Functional Programming, pages 66--164. Springer LNCS 5832, 2008.
[7]
}}J. Fokker. Functional parsers. In J. T. Jeuring and H. J. M. Meijer, editors, Advanced Functional Programming, First International Spring School, number 925 in LNCS, pages 1--23, 1995.
[8]
}}J. Nathan Foster, Alexandre Pilkiewicz, and Benjamin C. Pierce. Quotient lenses. In Proceeding of the International Conference on Functional Programming (ICFP '08), pages 383--396, New York, 2008.
[9]
}}Nathan J. Foster, Michael B. Greenwald, Jonathan T. Moore, Benjamin C. Pierce, and Alan Schmitt. Combinators for bi-directional tree transformations: A linguistic approach to the view update problem. In Proceedings of the symposium on Principles of Programming Languages (POPL '05), pages 233--246, New York, 2005.
[10]
}}Ralf Hinze. Formatting: a class act. Journal of Functional Programming, 13(5):935--944, 2003.
[11]
}}Christian Hofer, Klaus Ostermann, Tillmann Rendel, and Adriaan Moors. Polymorphic embedding of DSLs. In Proceedings of the Conference on Generative Programming and Component Engineering (GPCE '08), pages 137--148, New York, October 2008.
[12]
}}John Hughes. The Design of a Pretty-printing Library. In J. Jeuring and E. Meijer, editors, Advanced Functional Programming, pages 53--96. Springer LNCS 925, 1995.
[13]
}}John Hughes. Generalising monads to arrows. Science of Computer Programming, 37:67--111, May 2000.
[14]
}}Graham Hutton and Erik Meijer. Monadic parsing in Haskell. Journal of Functional Programming, 8(4):437--444, 1998.
[15]
}}Patrik Jansson and Johan Jeuring. Polytypic compact printing and parsing. In European Symposium on Programming, pages 273--287. Springer LNCS 1576, 1999.
[16]
}}Patrik Jansson and Johan Jeuring. Polytypic data conversion programs. Science of Computer Programming, 43(1):35--75, 2002. Oleg Kiselyov. Type-safe functional formatted IO. Available at http://okmij.org/ftp/typed-formatting/, 2008.
[17]
}}Edward A. Kmett. category extras: Various modules and constructs inspired by category theory. Available at http://hackage.haskell.org/package/category-extras, 2008.
[18]
}}Daan Leijen and Erik Meijer. Parsec: Direct style monadic parser combinators for the real world. Technical Report UU-CS-2001-27, Department of Computer Science, Universiteit Utrecht, 2001.
[19]
}}Conor McBride and Ross Paterson. Applicative programming with effects. Journal of Functional Programming, 18(1):1--13, 2008.
[20]
}}Shin-Cheng Mu, Zhenjiang Hu, and Masato Takeichi. An injective language for reversible computation. In Proceedings of the International Conference on Mathematics of Program Construction (MPC '04). Springer Verlag, 2004.
[21]
}}Nicolas Oury and Wouter Swierstra. The power of pi. In Proceedings of the International Conference on Functional Programming (ICFP '08), pages 39--50, New York, 2008.
[22]
}}Tim Sheard and Simon Peyton Jones. Template meta-programming for Haskell. SIGPLAN Not., 37(12):60--75, 2002.

Cited By

View all

Index Terms

  1. Invertible syntax descriptions: unifying parsing and pretty printing

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 45, Issue 11
    HASKELL '10
    November 2010
    156 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/2088456
    Issue’s Table of Contents
    • cover image ACM Conferences
      Haskell '10: Proceedings of the third ACM Haskell symposium on Haskell
      September 2010
      166 pages
      ISBN:9781450302524
      DOI:10.1145/1863523
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 30 September 2010
    Published in SIGPLAN Volume 45, Issue 11

    Check for updates

    Author Tags

    1. embedded domain specific languages
    2. invertible computation
    3. parser combinators
    4. pretty printing

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)23
    • Downloads (Last 6 weeks)2
    Reflects downloads up to 21 Dec 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2020)Invertible Bidirectional Metalogical Translation Between Prolog and RuleML for Knowledge Representation and QueryingRules and Reasoning10.1007/978-3-030-57977-7_8(112-128)Online publication date: 29-Jun-2020
    • (2019)En Garde! Unguarded Iteration for Reversible Computation in the Delay MonadMathematics of Program Construction10.1007/978-3-030-33636-3_13(366-384)Online publication date: 7-Oct-2019
    • (2019)Composing Bidirectional Programs MonadicallyProgramming Languages and Systems10.1007/978-3-030-17184-1_6(147-175)Online publication date: 6-Apr-2019
    • (2018)FliPpr: A System for Deriving Parsers from Pretty-PrintersNew Generation Computing10.1007/s00354-018-0033-736:3(173-202)Online publication date: 27-Aug-2018
    • (2017)Generic packet descriptions: verified parsing and pretty printing of low-level dataProceedings of the 2nd ACM SIGPLAN International Workshop on Type-Driven Development10.1145/3122975.3122979(30-40)Online publication date: 3-Sep-2017
    • (2016)A Classical Propositional Logic for Reasoning About Reversible Logic CircuitsProceedings of the 23rd International Workshop on Logic, Language, Information, and Computation - Volume 980310.1007/978-3-662-52921-8_4(52-67)Online publication date: 16-Aug-2016
    • (2014)Parsing in a Broad SenseModel-Driven Engineering Languages and Systems10.1007/978-3-319-11653-2_4(50-67)Online publication date: 2014
    • (2013)FliPprProceedings of the 22nd European conference on Programming Languages and Systems10.1007/978-3-642-37036-6_6(101-120)Online publication date: 16-Mar-2013
    • (2013)Isomorphic Interpreters from Logically Reversible Abstract MachinesReversible Computation10.1007/978-3-642-36315-3_5(57-71)Online publication date: 2013
    • (2012)Every bit countsJournal of Functional Programming10.1017/S095679681200026322:4-5(529-573)Online publication date: 1-Aug-2012
    • Show More Cited By

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media