Evaluator Hooking ("RebindableSyntax")

That method makes multiple calls to PARSE, updating the position of a data variable as it goes.

I'll just point out you could do this with a YIELDER (GENERATOR that takes parameters on each call). That avoids having to update DATA's position...the PARSE just gets suspended on the stack but with the parse state preserving the current position, all as part of a single operation:

fence!-EVAL: yielder [rule [fence!]] [
    rule: as block! rule
    parse data [opt some [let ^result: rule (yield ^result)]]
]

And if you use the ACTION! combinator you can avoid the temporary variable:

fence!-EVAL: yielder [rule [fence!]] [
    rule: as block! rule
    parse data [opt some /yield rule]]
]
1 Like