[REBOL] Re: Need Some PARSE Help
From: gerardcote::sympatico::ca at: 18-Oct-2005 21:26
Thanks, Tom
I'll try to push this problem as far as possible without having to manage spacing by
myself - replacing/all "^/" with " " (single
space).
This has been done and now there are other subtleties that I must cope with. At first
they looked as parse flaws (reliability
problem) but it seems that the origin of some problems has to do with inconsistencies
in the input. Nevertheless when I apply other
optional rules, I can't eliminate their effect - at least for the moment.
I'll try harder and if I can't find it myself I'll ask help again.
Regards,
Gerard
> Hi Gerard,
> these can usually be fixed by using parse's /all refinement and
> handeling white space yourself. I find I almost allways do this
> when I am doing more than simple string splitting.
>
> make a rule that accepts white space and include it
> at all the places you need it.
> ...
> ws: charset [#" " #"^-" #"^/"]
> ...
> english-day: ["Fri." |"Sat." |"Sun." |"Mon." |"Tue." |"Wed." |"Thu."
> |"Every day" some ws]
> ...
> parse/all t4 rules2/expr
> ...
Thank you Tom. I'm sure I will need your strategy for some part of my work but for the
moment I went around.
While I was waiting for an answer, I tried to replace/all every newline with a single
space.
Now the next problem seems to be more of a limitation of PARSE than anything else but
I am misplaced to judge by myself about that.
I explain.
In chapter 15 of the Rebol core manual I saw that I can ask alternatives to the "to"
word as in :
parse string [
"a" | "the"
to "phone" (print "answer") |
to "radio" (print "listen") |
to "tv" (print "watch")
]
answer
At first sight my problem seems similar but Parse refuses to recognise my rule :