Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Complex Series Parsing (Part 2)

From: sterling::rebol::com at: 8-Mar-2001 16:17

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