REBOL 3.0

PARSE: definition of termination and BREAK

Carl Sassenrath, CTO
REBOL Technologies
12-Oct-2009 20:47 GMT

Article #0270
Main page || Index || Prior Article [0269] || Next Article [0271] || 2 Comments || Send feedback

Ok, from the prior posting, we've decided that iteration of rules will have no auto-termination based on the state of the input. This will be part of the A89 release.

NOTE: Users must be careful to avoid infinite loops.

For example, this is now an infinite loop:

parse "abc" [some ["a" | to end]]

because TO END is always TRUE and reaching the end of input is not a termination condition for the iteration.

We can call that an improper rule because it will always be true.

For an improper rule, to terminate the loop, you must use a BREAK:

parse "abc" [some ["a" | to end break]]
true

Note that BREAK simply stops the loop, it does not affect the result. For example:

parse "abc" [some ["a" break | to end]]
false

This is FALSE because only "a" was matched and TO END was never attempted.

Any bugs submissions posted for infinite loops on improper rules will be dismissed.

Updated (14-Oct):

I should note that currently (in A89) BREAK exits immediately and does not process NOT, THEN, SET, COPY, RETURN, REMOVE, INSERT, CHANGE or other such post-match options. In other words, you cannot say NOT BREAK, but you can say NOT "abc" BREAK.

2 Comments

REBOL 3.0
Updated 22-Apr-2024 - Edit - Copyright REBOL Technologies - REBOL.net