Re: PEG.js-like API for the pegs module

2018-12-27 Thread mashingan
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

Re: PEG.js-like API for the pegs module

2018-12-27 Thread chrisheller
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

Re: Functional Programming in Nim

2018-12-27 Thread rect0x51
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),

Re: Functional Programming in Nim

2018-12-27 Thread filip
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().

Re: How can we define a function that returns a type like a Union type?

2018-12-27 Thread mrsekut
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?

Re: PEG.js-like API for the pegs module

2018-12-27 Thread lqdev
That's not an option, I'm not using the JavaScript backend.