Staged selective parser combinators
File(s)3409002.pdf (792.32 KB)
Published version
OA Location
Author(s)
Willis, Jamie
Wu, Nicolas
Pickering, Matthew
Type
Journal Article
Abstract
Parser combinators are a middle ground between the fine control of hand-rolled parsers and the high-level almost grammar-like appearance of parsers created via parser generators. They also promote a cleaner, compositional design for parsers. Historically, however, they cannot match the performance of their counterparts.
This paper describes how to compile parser combinators into parsers of hand-written quality. This is done by leveraging the static information present in the grammar by representing it as a tree. However, in order to exploit this information, it will be necessary to drop support for monadic computation since this generates dynamic structure. Selective functors can help recover lost functionality in the absence of monads, and the parser tree can be partially evaluated with staging. This is implemented in a library called Parsley.
This paper describes how to compile parser combinators into parsers of hand-written quality. This is done by leveraging the static information present in the grammar by representing it as a tree. However, in order to exploit this information, it will be necessary to drop support for monadic computation since this generates dynamic structure. Selective functors can help recover lost functionality in the absence of monads, and the parser tree can be partially evaluated with staging. This is implemented in a library called Parsley.
Date Issued
2020-08-02
Date Acceptance
2020-06-19
Citation
Proceedings of the ACM on Programming Languages, 2020, 4 (ICFP), pp.1-30
ISSN
2475-1421
Publisher
Association for Computing Machinery (ACM)
Start Page
1
End Page
30
Journal / Book Title
Proceedings of the ACM on Programming Languages
Volume
4
Issue
ICFP
Copyright Statement
© 2020 Copyright held by the owner/author(s). This work is under a Creative Commons Attribution 4.0 License (https://creativecommons.org/licenses/by/4.0/)
License URL
Publication Status
Published
Article Number
ARTN 120