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

[REBOL] Re: How to Parse a Nested Block

From: ryanc:iesco-dms at: 17-Sep-2001 15:53

The problem is that there is no recursiveness to your rule, so it is only capable of parsing one block depth. The block, {[text[string!] size[integer!]]}, is two deep. By ignoring any depth, should return that value {[text[string!} since the second #"[" is blindly copied with the 'copy 'to. Some advice... Since your parsing rebol formatted words, load and parse them. something like this should then work: rule: [ any [ string! copy str (print ["purpose:" str])] some [ word! copy wrd (print ["parameter:" wrd]) | block! copy blk (print ["types:" blk]) | string! copy str (print ["description:" str]) | refinement! copy ref (print ["refinement:" ref]) ] ] --Ryan Tim Johnson wrote:
> I swear I'm as dumb as stump when it comes to parsing: but > I've got "problem" whose "solution" should enlighten me immensely. > Here 'tis: > I want to parse rebol code so that I "extract" the interface block > from a function. > The following script "isolates" the code in a block, but not if > there are inner blocks: > rule: [thru "[" copy block-contents to "]" (print block-contents)] > parse/all {["This is a block"]} rule > ; returns: > "This is a block" ; okay, that's what I want. Cool! > parse/all {[text[string!] size[integer!]]} rule > ; returns only > [text[string! ; bummer, not what I wanted > ; I wanted to see: text[string!] size[integer!] > ; in other words parsed to the matching closing bracket > ; What else to I need to do? > TIA > Tim > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst 707-468-5400