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

[REBOL] Re: (2) 'Parse is peculiar! - fresh start

From: arolls:bigpond:au at: 16-Dec-2000 23:16

> You're right Anton. 'name is assigned outside the sub-block and can't be > referenced in it. Either the usual rebol word-within-context > system doesn't > apply to parse or it doesn't assign name until it reachs the last > ']' in the > sub-block.
That's not why! :) There is no such limitation. It's the mistake pointed out earlier by Pekr. The (print name) *should* be after the final end-bracket ] in the sub-rule [thru {<} 4 digits {>}]. The copy expects a successful sub-rule after 'name, before it assigns 'name a value. But the sub-rule tries print out 'name first. This is like trying to say:
>> name: rejoin ["<1234>" name]
** Script Error: name has no value. ** Where: name You get this error because rejoin ["<1234>" name] happens first. 'name has no value and therefore can't be evaluated. You probably didn't catch this problem with your advanced parse because 'name was set a value in an earlier test. Try this out: line1: "Ju<li>e<><><<1234>" id: [thru "<" 3 4 digits ">"] rule: [a: some [id | [skip b:]] (print copy/part a b)] parse line1 rule 'a is set to the beginning of the input. 'some keeps trying to match the 'id. If it can't, which is true for the first 12 characters, it just 'skips over a character and sets 'b to that position. After it has got through the guts of 'rule, it prints out all the stuff between 'a and 'b. Anton.