The entire string represents a series of events over time, starting at the
top of the output, and making its way down. The tags "fire" as they are
processed, and the corresponding ending tags </tag1> represent "stop" The
<text> tag is can have these other "events" embedded. In my particular
case, no non <text> tags will have other non <text> tags embedded within,
but I imagine one day they would.
y: [<tag0></tag0> <text> this and that <tag1>those </tag1>and
these</text><tag2></tag2><text>There and then</text>]
out: [
<tag0> ; fire
</tag0> ; stop
<text> this and that ;fire
<tag1> ;fire
<text> those ;continue
</tag1> ;stop
<text> and these ;continue
</text> ;stop
<tag2> ; fire
</tag2> ;stop
<text> There and then ;fire
</text> ;stop
]
----- Original Message -----
From: "Petr Krenzelok" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 09, 2001 4:06 AM
Subject: [REBOL] Re: Complex Series Parsing (Part 2)
>
> ----- Original Message -----
> From: Terry Brownell <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, March 09, 2001 10:25 AM
> Subject: [REBOL] Re: Complex Series Parsing (Part 2)
>
>
> > This is on the right track. But more complexity would arise... here is
an
> > advanced XML structure...
> >
> > y: [<tag0></tag0> <text> this and that <tag1>those </tag1>and
> > these</text><tag2></tag2><text>There and then</text>]
> > output would be...
> > out: [
> > <tag0>
> > </tag0>
> > <text> this and that
> > <tag1>
> > <text> those
> > </tag1>
> > <text> and these
> > </text>
> > <tag2>
> > </tag2>
> > <text> There and then
> > </text>
> > ]
>
> I am sorry but I can't understand the reason you want the input in above
> state. It's imo buggy. So you manually insert <text> tag in fron of each
> text, while real <text> tag exists too? Just look at your output - you
have
> 3 <text> tags while you have only one closing </text> tag. Is that correct
?
>
> -pekr-
>
> >
> >
> > There is method to the madness, I've got the "madness" part down pat,
now
> if
> > I could only come up with "the method".
> >
> > Thanks
> > Terry Brownell
> >
> > ----- Original Message -----
> > From: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Thursday, March 08, 2001 4:17 PM
> > Subject: [REBOL] Re: Complex Series Parsing (Part 2)
> >
> >
> > >
> > > I'm not sure I understand what you are really trying to do. Usually
> > > with parse, once you describe the format of what you want to parse and
> > > the output wou desire, the parse rules just fall out onto the screen.
> > > Correct me if I'm wrong:
> > >
> > > Input is a block with the following format:
> > > A <text> tag followed by a series of words with any number of non
> > > <text> or </text> tags interspersed and ends with a </text> tag.
> > >
> > > The desired output is the same block except that every place there is
> > > a non <text> tag in the block a <text> tag should be placed after it
> > > and before the next series of words. The ending </text> tag should be
> > > removed.
> > >
> > > For this you don't need parse at all. Just march through the block
> > > and insert the new <text> tag as needed:
> > > y: [
> > > <text> This is some text <tag> with a tag added </tag> and then some
> text
> > </text>
> > > ]
> > >
> > > forall y [
> > > all [tag? y/1 y/1 <> <text> y/1 <> </text> insert next y <text>]
> > > all [y/1 = </text> remove y y: back y]
> > > ]
> > >
> > > probe y: head y
> > >
> > > Perhaps your rules are a bit more complicated in which caase you need
> > > to define them and then see what's the best way to do it. Parse may
> > > be necessary but this simple case can be done quickly another way.
> > >
> > > Sterling
> > >
> > > > Hello all.
> > > >
> > > > How do you parse this...
> > > > y: [
> > > > <text> This is some text <tag> with a tag added </tag> and then some
> > text </text>
> > > > ]
> > > >
> > > >
> > > > So that you get this
> > > >
> > > > n: [
> > > > <text> This is some text
> > > > <tag>
> > > > <text> with a tag added
> > > > </tag>
> > > > <text> and then some text
> > > > ]
> > > >
> > > > I tried this...
> > > >
> > > > n: []
> > > > z: parse y none
> > > >
> > > > foreach val z [
> > > > either find val "<" [append n val] [append n rejoin [{<text> } val]]
> > > > ]
> > > >
> > > > But then I get
> > > >
> > > > n: [
> > > > <text>
> > > > <text> This
> > > > <text> is
> > > > <text> some
> > > > <text> text
> > > > <tag>
> > > > <text> with
> > > > <text> a
> > > > <text> tag
> > > > <text> added
> > > > </tag>
> > > > <text> and
> > > > <text> then
> > > > <text> some
> > > > <text> text
> > > > </text>
> > > > ]
> > > >
> > > > So how do I "collect" all the text until the next "tag"?
> > > >
> > > > Terry Brownell
> > > >
> > > > --
> > > > To unsubscribe from this list, please send an email to
> > > > [EMAIL PROTECTED] with "unsubscribe" in the
> > > > subject, without the quotes.
> > > >
> > > >
> > >
> > > --
> > > To unsubscribe from this list, please send an email to
> > > [EMAIL PROTECTED] with "unsubscribe" in the
> > > subject, without the quotes.
> > >
> >
> > --
> > To unsubscribe from this list, please send an email to
> > [EMAIL PROTECTED] with "unsubscribe" in the
> > subject, without the quotes.
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.