tags:

views:

86

answers:

1

I read chapter 15: http://www.rebol.com/docs/core23/rebolcore-15.html#section-8"

spacer: charset reduce [tab newline #" "]
spaces: [some spacer]
rule: ["a" spaces "b" spaces "c"]
parse/all "a b c" rule

is OK but if I change rule to just

rule: ["a" spaces copy varb to spaces "c"]
parse/all "a b c" rule

Rebol Console outputs error:

** Script Error: Invalid argument: some spacer
** Where: halt-view
** Near: parse/all "a b c" rule
>>

Why ?

Thanks.

+3  A: 

In REBOL 2 the argument of the TO operation of PARSE can't be a complex rule - it must be a literal value or character set. The code [to spaces] is equivalent to [to [some spacer]] and that just won't work. In your example you can convert [to spaces] to [to spacer spaces] and it should work just fine.

There are tricks to get around this, that mostly involve refactoring the [to [some spacer]] to be [any non-spacer] where non-spacer is the complement of the spacer character set.

It is intended that this will be fixed in REBOL 3, but that fix hasn't been done yet, and complementing a character set doesn't work as well because of Unicode. Stick with REBOL 2 for now.