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

[REBOL] Re: Strange parsing behavior

From: brett:codeconscious at: 3-Aug-2002 10:03

Hi Robert, I run your code and I get an error straight away: ** Script Error: string1 has no value ** Where: rejoin ** Near: mold name: get name So you probably had string1 set before you ran your test code.
> rule1: [start: copy string1 [to " - " (?? string1) | to newline] copy > string2 to end]
To start, lets just look at the first COPY in your Rule1. The variable is string1, the pattern is [to " - " (?? string1) | to newline] Rule1 looks bad to me because you are asking parse to COPY the input stream matched by the pattern into string1, but then from inside the pattern (and therefore before the pattern completes) you try to print string1. So the short answer to your first question is - nothing has been copied to string1 by the time you want to print it from inside the rule.
> - After the parsing string1 holds what I did expect in the > first place too. This indicates that the varaibles input > gets copied to will be changed after the parsing. But when and how?
When the pattern completes (after the first ] ). Compare with this:
>> parse/all "this is a - parsing test" [copy string1 to " - " (??
string1)] string1: "this is a" == false In this case the pattern is just to "- " and so copy has finished by the time string1 is printed.
> Rule2: > - This time the string1 is as expected inside the rule but > changes to include the to " - " sequence after the parsing > > Any idea what's up here? Is this a bug? Robert
Same explanation as for Rule1. Not a bug. Regards, Brett.