Back to Search Start Over

A new view on parser combinators

Authors :
Pieter Koopman
Rinus Plasmeijer
Source :
IFL
Publication Year :
2019
Publisher :
ACM, 2019.

Abstract

Parser combinators offer a concise and fast way to produce reasonably efficient parsers. The combinator libraries themselves can be small and provide an elegant application of functional programming techniques. They are one of the success stories in functional programming that are also ported to many other languages. In this paper, we illustrate that we can make the parser combinators more general by modeling them as a tagless domain specific language. The idea is to replace the ordinary combinators by a set of type constructor classes. By making different implementations of this class we can assign various interpretations of one and the same grammar specification. The set of type classes makes the DSL type-safe and extendable without needing to change existing parts and implementations. This enables us to make multiple interpretations, views, of the specified grammar. In this paper we show views for deterministic parsing, nondeterministic parsing, generating possible parse trees produced by the grammar without needing the corresponding input, generating inputs accepted by the grammar, adapting the grammar rules such that the parser combinators can handle left-recursion and so on. This makes our multi-view parser combinators more powerful than the existing approaches.

Details

Database :
OpenAIRE
Journal :
Proceedings of the 31st Symposium on Implementation and Application of Functional Languages
Accession number :
edsair.doi...........d33de689a18bcd9c806e4577ebef02d9