Closed bencochran closed 8 years ago
This is great, thank you!
I wonder if we should document that you can run into trouble with e.g.:
many(not(something))
Since not
doesn’t advance the cursor, it can infinite loop. Alternatively, maybe many
should not repeat at the same index.
Any thoughts?
That’s a good catch.
Poked around at making many
(and therefore also some
) fail if they don’t consume any input. I’m not convinced it’s the cleanest approach, so I may come take a second look at it, but wanted to get it up here for others’ eyes in the meantime.
Ok, coming back for a second ponder: the current approach is sitting alright with me. The only hesitation I have is wondering if an error is the correct choice. That is, I could see an argument that some(not(x))
should match once then bail (that is, it would effectively produce [()]
). But that feels like it would be uglier to implement, and I’m not convinced there’s a real reason for that behavior above this one.
:+1: Thanks @bencochran. This is looking really good.
Awesome, thank you!
Implements a negative lookahead combinator as described in #51.
I started with it called
notFollowedBy
, but most of my uses look something likemany(not(something) *> any)
and havingnotFollowedBy(something) *> any
felt confusing.This could also yield a subtraction combinator (#59) via
not(right) *> left
if we want one.