Streaming parsers in D a novel design

Petar Petar
Tue Apr 18 13:01:40 UTC 2023


On Tuesday, 18 April 2023 at 08:13:05 UTC, Dmitry Olshansky wrote:
> A streaming parser is doing 2 things:
> - waiting for input
> - processing the current input and spitting out Events
>
> This maps to D beautifully:
>
> 1. Waiting for input means it's an OutputRange with explicit 
> put method!
>
> 2. Processing events means it's an InputRange of events. It may 
> even be ForwardRange, mine first of this kind is Forward range.
>
> Destroy!
>
> --
> Olshansky Dmitry

Sounds like a natural fit! I think it's interesting to explore 
related concepts that other languages have like their versions of 
iterators/ranges, but also streams, observables, interaction with 
promises (observables vs async iterables). Another related topic 
is validation vs parsing (converting data from unstructured input 
to a more structured form). I don't have time to discuss in 
detail at the moment, so I'll just share a few links.


https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
https://serokell.io/blog/parser-combinators-in-haskell

http://csl.stanford.edu/~christos/pldi2010.fit/meijer.duality.pdf
https://www.youtube.com/watch?v=sTSQlYX5DU0&ab_channel=ReactConference

https://dev.solita.fi/2021/10/14/grokking-clojure-transducers.html
https://www.youtube.com/watch?v=6mTbuzafcII
https://hypirion.com/musings/recursive-transducers
https://hypirion.com/musings/haskell-transducers

https://www.youtube.com/watch?v=vohGJjGxtJQ&ab_channel=CppCon
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2300r5.html


More information about the Digitalmars-d mailing list