AFAIK, there's no a single way to do it with pegs module. With pegs module you
can test whether the string satisfies the definition and you should code what
to do with captured instance
for example
import pegs
var
ops = peg"\skip (\s*) '+' / '-' / '/' / '*'"
pr
By the way, here is a little more detail on one of the issues that I
encountered. In pegs.nim (0.19.2 and devel), in the parsePeg proc, the
PegParser var that is created seems to get re-initialized after the init call
returns when running in the VM at compile time.
The existing code looks like
Regarding that... what is currently the preferred way to do laziness in Nim?
Hand-writing closure iterators works, but is there any established library? I
know of [lazy](https://rawgit.com/petermora/nimLazy/master/doc/lazy.html) and
[iterutils](https://hookrace.net/nim-iterutils/iterutils.html),
I assume you have tried the `sequtils` module from the standard library. Your
examples should work with it. My only complaint with sequtils is that the
functions don't work with iterators so your code gets sprinkled with toSeq().
Thanks to your answer my problem has been solved.
By the way, can you solve this problem using concepts? Or do not you use
concepts in such a situation?
That's not an option, I'm not using the JavaScript backend.