Implicit Capture In PARSE - How To Get It?

ISO-8601 dates are very close to Rebol dates, but just different enough to make it a pain.

; ISO-8601
2021-09-15T12:20:53-04:00

; Rebol
15-Sep-2021/12:20:53-04:00

Are Rebol dates more readable? Yes. Are they so much better as to make it worthwhile to buck the standard? :man_shrugging: Are they in conflict with generalized PATH! representation? :man_shrugging:

Nevermind, This Post Is About Something Else

Let's say I just want to capture the YEAR, the MONTH, and the DAY out of an ISO-8601 date.

uparse isodate [
    year: between <here> "-"
    month: between <here> "-"
    day: between <here> "T"
    ...
 ]

Despite having BETWEEN, it's laborious. (Historical Rebol needs copy to "-" followed by a SKIP, even more convoluted).

It needs a shorthand. We have TAG! at our disposal, still:

uparse isodate [year: <*> "-" month: <*> "-" day: <*> "T" ...]

And it could be plain *:

uparse isodate [year: *, "-", month: *, "-", day: *, "T", ...]

But I kind of find myself wishing for another lexical type that means "capture". I'd thought about this as being the meaning of @xxx before the current interpretation.

I'm nearly certain we'll have $word, $[bl o ck], $(gr o up) and friends. Maybe that?

uparse isodate [$year "-" $month "-" $day "T" ...]

Though since the general meaning would be "get-environment-variable" this would raise questions about dialects bending the meaning of things so severely.

It Feels Weak To Not Have An Answer For This

Other parsing systems will always seem like they have an edge if there isn't a shorthand for this "capture until the next rule".

2 Likes

As it happens, we do now have the $XXX types. And they do not mean "environment variable" in the main evaluator... they relate to applying the "current binding" of the evaluator onto the thing in hand.

>> x: 10

>> get 'x
** Error: x is not bound

>> get $x
== 10

As far as PARSE goes, "capture thing at current position into a variable" is still a compelling thing to do succinctly. Though having $ not related to binding would be a loss (given that we know that there need to be some binding assistance for propagating binding while parsing, to keep dialect implementation from being too much of a hassle.)

So could it be both? Could $xxx capture the current thing, and apply the binding (if applicable?) Binding wouldn't be applicable to strings (though it could if you reached the string via a SUBPARSE of a block).

Don't know, just wanted to give this thread a bump since $ types exist now.