Comments on: Recursion Safe PARSE Rules
Ladislav has created a useful function, an idiom, for recursive (and someday threaded) PARSE rules.
This function is useful because PARSE rules often store data in variables which, depending on how you handle them, can be overwritten by rule recursion. (Which is done often in parsing.)
Ladislav points out an example rule like this:
rule: [ "b" (print 1) | a: "a" rule "a" b: (print subtract index? b index? a) ]
Here, because the a: is set before the re-entry into rule, it will be overwritten.
Ladislav's solution is called use-rules (as in the use function for rules). It is posted on REBOL.org at use-rule function. It includes a simple example.
A handy idiom.
Post a Comment:
You can post a comment here. Keep it on-topic.
Updated 10-Jun-2023 - Copyright Carl Sassenrath - WWW.REBOL.COM - Edit - Blogger Source Code