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

[REBOL] Re: Parse limitation ?

From: robert:muench:robertmuench at: 9-Oct-2003 11:07

On Wed, 8 Oct 2003 12:10:42 +0200, patrick à la poste <[patrick--philipot--laposte--net]> wrote:
> myText: {<A HREF="#section1"><IMG SRC="foobar.gif"><A HREF="#section1">}
Hi, one other trick beside doing by-hand backtracking (which is very powerful) is to define more than one rule set and use parse several times. Why try to write on rule set at all? No one tries to solve a programming problem with one function. So, what could be done: 1. We could parse for < and > and copy all we have. 2. The copied string can than be parsed again with an other rule set. parse myText [ some [ to "<" copy sub-parse to ">" ( parse sub-parse [ "HREF=" (print "href") | "SRC=" (print "src") ]) ] ] What needs to be remember is that a rule which uses | only hit once. The first part that makes it to the end will terminate further evaluation. The logic is clear, the rule did it's job, why continue? While doing make-doc-pro I have used this approach at several places, where parse rules would get very complicated otherwise. -- Robert M. Münch Management & IT Freelancer Mobile: +49 (177) 245 2802