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

[REBOL] Re: Parse versus Regular Expressions

From: andreas:bolka:gmx at: 3-Apr-2003 10:56

Thursday, April 3, 2003, 9:39:43 AM, Ladislav wrote:
> Then he asked me, whether the following equation could be easily > rewritten for PARSE too: > Y = Y.a + b > The result of the equation is known, it is: > Y = ba* > , i.e. in PARSE notation: > y: [#"b" any #"a"] > Noticeably, the "dumb" approach to the equation rewriting: > y: [[y #"a"] | #"b"]
I just want to add, that this is not necessarily a "dump" approach but rather a left-recursive approach. Wether a given parser can handle left-recursive grammars depends on the parser's internal implementation. There are certainly situations where left-recursive grammars are by far more natural and elegant when compared to their non left-recursive aequivalents.
> didn't "fire" any error, stack overflow, or any unusual exception. > Nevertheless, it didn't work: > parse "b" y ; == true > parse "ba" y ; == false > Any ideas?
Not really, sorry (unless you count my conclusion below as "ideas" :). The problem here is that we (at least I :) do not know how 'parse is implemented internally (and I have not attempted to gain more knowledge by experimentation). The only things I dare to conclude from my experiences (or from your examples): - 'parse is not able to handle left-recursive grammars - 'parse does not tell you, when it encounters left recursion, it "silently" pretends that the sentence (the "ba" in your example) does not match the grammar. Not a very desireable behaviour, imho. -- Best regards, Andreas mailto:[andreas--bolka--gmx--net]