Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

parse and infinite loops (was: parse, again)

 [1/4] from: lmecir:mbox:vol:cz at: 6-Nov-2001 11:57


Hi Halvard & Rebols, <<Just a sec... Why does parse "" [to end to end] yield 'true? What happens when 'parse has done the first [to end]? Where is 'parse at then? And wouldn't it be simple for rebol to know that once 'parse has reached 'end, all further parse instructions must fail or be ignored? >> You would be the first one who would see the trouble with such a simplistic approach (how would you distinguish the cases): parse "a" ["a" opt "b" opt "c"] as opposed to parse "a" ["a" opt "b" "c"] The possibility of (infinite) loops is inevitable, if PARSE has to be universal enough (bitter but true). Simple infinite loops: [some [any skip]] [some [opt "a"]] [some [to end]] rule: [to end rule] [some none] [some []] The rule of thumb for not being bugged by such kind of bugs is to use rules that either consume at least something from input or, if they don't, then they should finish their work.

 [2/4] from: hallvard:ystad:helpinhand at: 6-Nov-2001 12:42


Ladislav Mecir skrev (Tuesday 06.11.2001, kl. 11.57):
>The rule of thumb for not being bugged by such kind of bugs is to use >rules >that either consume at least something from input or, if they don't, then >they should finish their work.
Ah! So [to end] doesn't actually consume whatever is left of parse's input? ~H

 [3/4] from: brett::codeconscious::com at: 6-Nov-2001 22:56


> >The rule of thumb for not being bugged by such kind of bugs is to use > >rules > >that either consume at least something from input or, if they don't, then > >they should finish their work. > > Ah! So [to end] doesn't actually consume whatever is left of parse's
input?
I think of [to end] as being equivalent to: input: tail input Brett.

 [4/4] from: lmecir:mbox:vol:cz at: 6-Nov-2001 13:35


Ladislav Mecir skrev (Tuesday 06.11.2001, kl. 11.57):
>The rule of thumb for not being bugged by such kind of bugs is to use >rules >that either consume at least something from input or, if they don't, then >they should finish their work.
<<Ah! So [to end] doesn't actually consume whatever is left of parse's input?>> Do not forget, that it may be nothing sometimes...