PARSE: do you want BREAK?

Carl Sassenrath, CTO
REBOL Technologies
6-Oct-2009 18:39 GMT

Article #0262
Main page || Index || Prior Article [0261] || Next Article [0263] || 19 Comments || Send feedback

The break word is not yet defined in parse, but it can be added if desired. So, say something if you want it.

Note that we have fail now, which fails a specific rule, and moves to the next alternate:

>> parse "abc" ["abc" fail | "bcd"]
== false
>> parse "abc" ["ab" fail | "abc"]
== true
>> parse "bcd" ["ab" fail | "bcd"]
== true

But, fail does not let you fail the entire rule block, so perhaps that's a choice for break:

>> parse "bcd" ["b" break | "bcd"]
== false

Some developers have suggested a return value for break, but I'm not sure why that is useful.

Also, note that return is now implemented for returning from parse via an internal throw action.

>> parse "bcd" ["abc" | "bcd" return ('ok) | "cab"]
== ok

(Note: there's another form for return, but it's not working in A87.)


Updated 24-Jun-2024 - Edit - Copyright REBOL Technologies -