nitely / nim-regex

Pure Nim regex engine. Guarantees linear time matching
https://nitely.github.io/nim-regex/
MIT License
227 stars 20 forks source link

Support streaming input. #14

Open Varriount opened 6 years ago

Varriount commented 6 years ago

There are times when one has a large (or possibly unlimited) amount of input. It would be nice to have match procedures that would accept a moreDataProc or similar parameter, to call when the internal logic needs more data from the string.

nitely commented 6 years ago

Sure, it could take a closure function, a closure iterator, a Stream object, or something-something concepts (that would handle any iterator either string or stream). Problem is there isn't a buffered stream (or a unicode string stream for that matter) in the stdlib. I tried to implement something like this long ago [0], but it was crap. We need better IO primitives in the stdlib (similar to golang probably), otherwise the regex API would be really hard to use.

[0] https://github.com/nim-lang/Nim/pull/6745

nitely commented 6 years ago

I guess I can always deprecate the new functions later when there's a better way (or I find one) :thinking: