REBOL 3.0

Comments on: 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

Comments:

Maxim Olivier-Adlhoch
12-Oct-2009 18:00:19
Of note... the term "improper rule" should be added as an official concept in the PARSE glossary.

it should be defined clearly, so people can refer to it in docs, discussions, and as a concept for new users to watch out for.

Brian Hawley
12-Oct-2009 18:47
Agreed, Maxim. Definitely a documentation issue.

Sorry for retaining another gotcha, Fork, but to do otherwise would reduce the power of PARSE. Newbies can't win them all - sometimes we need to get work done.

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

R3-0270


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 28-Mar-2024 - Edit - Copyright REBOL Technologies - REBOL.net