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

[REBOL] Re: Strange parsing behavior

From: robert:muench:robertmuench at: 3-Aug-2002 13:04

> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]] > On Behalf Of Gabriele Santilli > Sent: Saturday, August 03, 2002 11:02 AM > To: Robert M. Muench > Subject: [REBOL] Re: Strange parsing behavior > >> parse "this is a test" [copy word [to "a" to end]] > == true > >> word > == "this is a test" > > It's the end of the sub-rule, since COPY copies what is > matched by the next element in the rule, that is the > sub-rule in this case.
Ok, ok but I still find it a bit strange. In your example to "a" can be deleted and the result won't change. I would expect the resulting string to grow while parsing is done:
>> parse "this is a test" [copy word [to "a" (?? word) to end (??
> word: "this is" > word: "this is a test" > Place COPY *inside* the sub-rule if > you want to get the result you were expecting.
Unfortunately this doesn't work for complex cases. Try the following, which can't be done: Text: "this-is-a test of some parsing^/ this-is-a - test of some parsing" The result should be Text: ["this-is-a test of some parsing" "this-is-a" "test of some parsing"] You have to solve the problem to trigger on " - " or 'newline whichever comes first ;-). Robert