Changing a rule on the fly

A parsing rule can be changed while it is being applied, as the following example shows:

rule: ["x" | "y"]parse "xyyxqyyxz" [    some [        rule    |        "q" (append rule [ | "z" ])    ]]   ;== true

When the letter q is found, the rule is enhanced so that it also matches the letter z. That's why parse returns true in this case.

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.