Help with parsing
[1/4] from: richard_dixon:mail at: 22-Feb-2002 2:43
I am learning Rebol Core. It is unclear to me why the following statements fail. Any
help in understanding what is wrong with the following statements would be appreciated.
>> digits: [["0"] | ["1"] | ["2"] | ["3"] | ["4"] | ["5"] | ["6"] | ["7"] | ["8"] | ["9"]
]
== [["0"] | ["1"] | ["2"] | ["3"] | ["4"] | ["5"] | ["6"] | ["7"] | ["8"] | ["9"]]
>> parse {xx7xx9} [to digits copy answer to end]
** Script Error: Invalid argument: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
** Where: halt-view
** Near: parse "xx7xx9" [to digits copy answer to end]
[2/4] from: al:bri:xtra at: 22-Feb-2002 22:23
Richard wrote:
> It is unclear to me why the following statements fail. Any help in
understanding what is wrong with the following statements would be
appreciated.
> >> digits: [["0"] | ["1"] | ["2"] | ["3"] | ["4"] | ["5"] | ["6"] | ["7"]
| ["8"] | ["9"] ]
> == [["0"] | ["1"] | ["2"] | ["3"] | ["4"] | ["5"] | ["6"] | ["7"] | ["8"]
| ["9"]]
> >> parse {xx7xx9} [to digits copy answer to end]
> ** Script Error: Invalid argument: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
> ** Where: halt-view
> ** Near: parse "xx7xx9" [to digits copy answer to end]
> >>
'to in the 'parse rule doesn't work with "|". It requires a single value
only, not a block of values. It's a deficiency in Rebol. A better way of
describing 'digits is:
Digit: charset "0123456789"
Digits: [some Digit]
I hope that helps!
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[3/4] from: lmecir::mbox::vol::cz at: 22-Feb-2002 11:42
Hi Richard,
you can use my parse enhancing functions as follows:
do http://www.sweb.cz/LMecir/parseen.r
digit: charset [#"0" - #"9"]
to-digit: to-rule [digit]
parse "xx7xx9" [to-digit copy answer to end]
answer
Cheers
L
P.S. you can find it at my rebsite (sites/Ladislav) too
<<From: "Richard Dixon">>
I am learning Rebol Core. It is unclear to me why the following statements
fail. Any help in understanding what is wrong with the following statements
would be appreciated.
>> digits: [["0"] | ["1"] | ["2"] | ["3"] | ["4"] | ["5"] | ["6"] | ["7"] |
["8"] | ["9"] ]
== [["0"] | ["1"] | ["2"] | ["3"] | ["4"] | ["5"] | ["6"] | ["7"] | ["8"] |
["9"]]
>> parse {xx7xx9} [to digits copy answer to end]
** Script Error: Invalid argument: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
** Where: halt-view
** Near: parse "xx7xx9" [to digits copy answer to end]
[4/4] from: richard_dixon:mail at: 2-Mar-2002 21:22
I have tried reaching yoursite several times but cannot. Is your site shutdown at certain
times?