[REBOL] Re: Parsing question
From: g:santilli:tiscalinet:it at: 13-Aug-2001 19:25
Hello Robert!
On 10-Ago-01, you wrote:
RM>> I'd suggest to describe the grammar of a line of text in
RM>> more detail; this way you'll get the parse rule for free.
RM> Hi, well ok here it is. Some parts are stripped to keep the
RM> mail lean.
[...]
Sorry, I think I was not clear. I didn't mean you should provide
us the rules in make-doc.r (they are available in the source
anyway for all of us to look at).
RM> I would like to parse for special character sequences in the
RM> block up to the 'newline and handle them. The situation is
What I meant was: if you are able to describe the grammar for a
generic line with "special chaacter sequences" then you will
easily get to the parse rule.
I'll try with an example. We want to parse:
"This is a *bold text*."
I can describe the grammar for a string like that as "zero or more
characters different from an asterisk, an asterisk, zero or more
characters different from an asterisk, an asterisk, zero or more
characters different from an asterisk". Turning it into PARSE
rules:
chars: complement charset "*"
[any chars "*" any chars "*" any chars]
Then we can add COPY to save the text:
[copy normal-text any chars "*" copy bold-text any chars "*" copy normal-text any chars]
This is of course a trivial example, but this way you should be
able to solve your problem. Or maybe I'll have some free time in
the next days and will try to come up with something.
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/