Using BREAK keyword
[1/3] from: brett::codeconscious::com at: 21-Sep-2003 12:12
I was going to rewrite my example code in:
http://www.codeconscious.com/rebol/parse-tutorial.html#WhenyoudoNOTwanttomat
chapattern
to use the Break keyword of Parse so that I could add it as a comparison.
Unfortunately I wasn't sure of how to do it to give the same results.
Any ideas?
Thanks,
Brett.
---
Website: http://www.codeconscious.com
Rebsite: http://www.codeconscious.com/index.r
[2/3] from: rotenca:telvia:it at: 21-Sep-2003 8:35
Hi Brett,
> to use the Break keyword of Parse so that I could add it as a comparison.
> Unfortunately I wasn't sure of how to do it to give the same results.
> Any ideas?
[end skip] and [break] are not the same.
The first fails the second breaks.
Examples:
parse "a" [some [break] "a"] ;== true
'some halts, but not fails.
parse "a" [some [end skip] "a"] ; == false
'some halts, because it fails.
With 'any, the difference cannot be detected, because its result is alway
positive, also if the rule fails.
parse "a" [any [end skip] "a"] ; == true
parse "a" [any [break] "a"] ;== true
There is little difference between break in parse and break in a cycle like
this:
forever [
break
]
It only breaks the cycle without changing its result.
---
Ciao
Romano
[3/3] from: brett:codeconscious at: 21-Sep-2003 21:07
> [end skip] and [break] are not the same.
> The first fails the second breaks.
Thanks Romano,
I've given up the idea of writing another version of that code example using
Break. Instead I have put in a few examples of using Break.
On a different note. I found a way to use the Escape key in those infinite
loop situations that sometimes occur when developing new rules.
Place a paren! within the Some or Any loop. Somehow it enables Escape key
processing.
That is - you can use the escape key with this:
; Hit escape to exit
parse [] [ any [ () none ] ]
but not with this:
; Careful - you will have terminate the process.
parse [] [ any [ none ] ]
Regards,
Brett.