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

[REBOL] Re: Parsing question

From: robert:muench:robertmuench at: 10-Aug-2001 18:30

> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of > Gabriele Santilli > Sent: Thursday, August 09, 2001 9:41 PM > To: [rebol-list--rebol--com] > Subject: [REBOL] Re: Parsing question > I'd suggest to describe the grammar of a line of text in more detail; this > way you'll get the parse rule for free.
Hi, well ok here it is. Some parts are stripped to keep the mail lean. ;-- Text Format Language: rules: [some parts] parts: [ newline | "***" text-line (if title [alert reform ["Duplicate title:" text]] emit title text) | ["===" | "-1-"] text-line (emit-section 1) | ["---" | "-2-"] text-line (emit-section 2) | ["+++" | "-3-"] text-line (emit-section 3) ... ;--Defaults: | example (emit code trim/auto code) | paragraph (either title [emit para para][emit title title: para]) | skip ] paragraph: [copy para to newline] I would like to parse for special character sequences in the block up to the 'newline and handle them. The situation is that if 'paragraph is reached, no other rule out of 'parts has matched the input stream. My idea was to use the same approach as in 'parts paragraph: [ some [ "*" copy boldtext to "*" (handle-bold-text) | "_" copy underlinetext to "_" (handle-underline-text) | copy para to newline ] ] But this doesn't seem to work. I thought 'some tries as long as possible to apply a rule and only if it doesn't succeeds, control is given back to the parent-rule block. Robert