Haskell and XML: generic combinators or type-based translation?
Proceedings of the fourth ACM SIGPLAN international conference on Functional programming
Packrat parsing:: simple, powerful, lazy, linear time, functional pearl
Proceedings of the seventh ACM SIGPLAN international conference on Functional programming
ICFP '03 Proceedings of the eighth ACM SIGPLAN international conference on Functional programming
Journal of Functional Programming
Fine-grained Visualization Pipelines and Lazy Functional Languages
IEEE Transactions on Visualization and Computer Graphics
Applicative programming with effects
Journal of Functional Programming
Proceedings of the 15th ACM SIGPLAN international conference on Functional programming
Journal of Visual Languages and Computing
Hi-index | 0.00 |
Parser combinators, often monadic, are a venerable and widely-used solution to read data from some external format. However, the capability to return a partial parse has, until now, been largely missing. When only a small portion of the entire data is desired, it has been necessary either to parse the entire input in any case, or to break up the grammar into smaller pieces and move some work outside the world of combinators.This paper presents a technique for mixing lazy, demand-driven, parsing with strict parsing, all within the same set of combinators. The grammar specification remains complete and unbroken, yet only sufficient input is consumed to satisfy the result demanded. It is built on a combinationof applicativeand monadicparsers. Monadic parsing alone is insufficient to allow a choice operator to coexist with the early commitment needed for lazy results. Applicative parsing alone can give partial results, but does not permit context-sensitive grammars. But used together, we gain both partiality and a flexible ease of use.Performance results demonstrate that partial parsing is often faster and more space-efficient than strict parsing, but never worse. The trade-off is that partiality has consequences when dealing with ill-formed input.