skip to main content
research-article

Parsing with first-class derivatives

Published:19 October 2016Publication History
Skip Abstract Section

Abstract

Brzozowski derivatives, well known in the context of regular expressions, have recently been rediscovered to give a simplified explanation to parsers of context-free languages. We add derivatives as a novel first-class feature to a standard parser combinator language. First-class derivatives enable an inversion of the control flow, allowing to implement modular parsers for languages that previously required separate pre-processing steps or cross-cutting modifications of the parsers. We show that our framework offers new opportunities for reuse and supports a modular definition of interesting use cases of layout-sensitive parsing.

References

  1. M. Adams, C. Hollenbeck, and M. Might. On the complexity and performance of parsing with derivatives. In Proceedings of the Conference of Programming Language Design and Implementation, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. M. D. Adams. Principled parsing for indentation-sensitive languages: Revisiting Landin’s offside rule. In Proceedings of the Symposium on Principles of Programming Languages, POPL, pages 511–522, New York, NY, USA, 2013. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. M. D. Adams and Ö. S. A˘gacan. Indentation-sensitive parsing for Parsec. In Proceedings of the 2014 ACM SIGPLAN Symposium on Haskell, Haskell ’14, pages 121–132, New York, NY, USA, Sept. 2014. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. Afroozeh and A. Izmaylova. One parser to rule them all. In 2015 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward!), pages 151–170. ACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. J. A. Brzozowski. Derivatives of regular expressions. Journal of the ACM (JACM), 11(4):481–494, 1964. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. N. A. Danielsson. Total parser combinators. In Proceedings of the International Conference on Functional Programming, ICFP, pages 285–296, New York, NY, USA, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. S. Erdweg, T. Rendel, C. Kästner, and K. Ostermann. Layoutsensitive generalized parsing. In Software Language Engineering, pages 244–263. Springer, 2012.Google ScholarGoogle Scholar
  8. P. Hudak. Modular Domain Specific Languages and Tools. In Proceedings of the International Conference on Software Reuse, pages 134–142. IEEE, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. G. Hutton. Higher-order functions for parsing. Journal of Functional Programming, 2:323–343, 7 1992.Google ScholarGoogle ScholarCross RefCross Ref
  10. G. Hutton and E. Meijer. Monadic parsing in haskell. Journal of functional programming, 8(04):437–444, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. T. Jim and Y. Mandelbaum. A new method for dependent parsing. In Proceedings of the Programming Languages and Systems: European Symposium on Programming, ESOP, pages 378–397. Springer, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. T. Jim, Y. Mandelbaum, and D. Walker. Semantics and algorithms for data-dependent grammars. In Proceedings of the Symposium on Principles of Programming Languages, POPL, pages 417–430, New York, NY, USA, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. O. Kiselyov. Iteratees. In Functional and Logic Programming, pages 166–181. Springer, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. P. J. Landin. The next 700 programming languages. Commun. ACM, 9(3):157–166, Mar. 1966. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. P. Ljunglöf. Pure functional parsing-an advanced tutorial. Licenciate thesis, Göteborg University and Chalmers University of Technology, Gothenburg, Sweden, 2002.Google ScholarGoogle Scholar
  16. S. Marlow (editor). Haskell 2010 language report. https:// www.haskell.org/onlinereport/haskell2010/, 2010.Google ScholarGoogle Scholar
  17. M. Might, D. Darais, and D. Spiewak. Parsing with derivatives: A functional pearl. In Proceedings of the International Conference on Functional Programming, ICFP, pages 189–195, New York, NY, USA, 2011. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. A. Moss. Derivatives of parsing expression grammars. CoRR, abs/1405.4841, 2014.Google ScholarGoogle Scholar
  19. Python Software Foundation. The Python language reference: Full grammar specification. https://docs.python.org/3. 5/reference/grammar.html. Accessed: 2015-03-24.Google ScholarGoogle Scholar
  20. J. J. Rutten. Automata and coinduction (an exercise in coalgebra). Springer, 1998.Google ScholarGoogle ScholarCross RefCross Ref
  21. S. D. Swierstra. Combinator parsing: A short tutorial. In Language Engineering and Rigorous Software Development, pages 252–300. Springer, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. P. Wadler. How to replace failure by a list of successes. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture, pages 113–128, New York, NY, USA, 1985. Springer-Verlag New York, Inc. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. J. Winter, M. M. Bonsangue, and J. Rutten. Context-free languages, coalgebraically. Springer, 2011.Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Parsing with first-class derivatives

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 51, Issue 10
            OOPSLA '16
            October 2016
            915 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/3022671
            Issue’s Table of Contents
            • cover image ACM Conferences
              OOPSLA 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications
              October 2016
              915 pages
              ISBN:9781450344449
              DOI:10.1145/2983990

            Copyright © 2016 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 19 October 2016

            Check for updates

            Qualifiers

            • research-article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!