It seemed we could have a shorter way to say to <end>
(or thru <end>
, they act the same).
>> parse "aabbcc" [some "a" to <end>]
== ""
In fact, what you want more often is probably elide to <end>
. Because the <end>
combinator currently evaluates to the end position of the series (hence the "" you see above, as the TO returns what its argument evaluates to.)
>> parse "aabbbcc" [some "a" elide to <end>]
== "a"
A kind of obvious choice for meaning this would be ...
>> parse "aabbbcc" [some "a" ...]
== "a"
(Initially I was skeptical of using ...
without some decoration, and did this with the TAG! of <...>
, but I think the reasons I was skeptical are probably not good reasons, and we should go ahead and make it easier on the eyes and easier to type.)
But Why Should It Only Work At The End?
This seems useful:
>> parse "aabbbcc" [... some "b" ...]
== "b"
But isn't that just a synonym for THRU, with the exception that if there's nothing to go THRU it assumes you mean <end>
?
Well, a synonym for THRU isn't really what you want. You'd probably like this to work:
>> parse "aabbbcc" [... some "x" | some "b" ...]
== "b"
In essence, you want it to implicitly wrap anything to the right--up to the next <...>
--in a BLOCK!, so act equivalently to:
>> parse "aabbbcc" [thru [some "x" | some "b"] elide to <end>]
== "b"
That's not possible for a normal combinator, you'd need a variadic one.
Today's approximation of variadic combinators is to just special-case the implementation directly in the BLOCK! combinator.
So...that's what I've done!
A more elegant way of writing the feature may come down the pipe someday. But this gives us a version we can use in the here and now.
It's experimental, so use with caution.