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

[REBOL] Re: Parse versus Regular Expressions

From: g:santilli:tiscalinet:it at: 5-Apr-2003 10:48

Hi Joel, On Saturday, April 5, 2003, 1:28:26 AM, you wrote: JN> The specific example at hand required the programmer to take action JN> to make the first alternative fail before PARSE would consider the JN> second. It would be nice if failure at the end of the *entire* rule JN> also caused backtracking so the programmer didn't have to do any JN> extra work. That would mean that we can no more use subblocks for parsing. I.e., if PARSE worked as you suggest, how would one write this? rule1: ["a" | "b"] rule2: ["c" rule1 "d"] On "cad", based on your suggestion, rule1 would not reach the end of the string and thus backtrack. Notice that you can't backtrack the whole rule because it can be composed of a complex network of subrules, each one having '| alternatives. Which one should backtrack? What happens to the code in parens? With REs you can do this, mainly because they are just patterns (and not grammars with possibly embedded code). Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r