From: Nikolai Weibull Date: 2005-07-22T06:21:18+09:00 Subject: Re: Rubys Regular Expression Engine Wolfgang N�dasi-Donner wrote: ^-- Sorry, but your missing proper encoding information. > Some weeks ago I sent a message here, "Onigurama - Problem with > Subexpression Call", sent on Montag, 27. Juni 2005 23:22 - > unfortunately there was no comment from someone. So I try to ask the > major part again. It's easier to track if you point to the number of the message instead. It can be found at http://www.ruby-talk.org/. > Onigurama does not recognize left recursion correctly. Why should it? (See below.) > As I wrote in my earlier message > > ----------------------------------------------------------- > orgstring= "5-((3+4)*5)+6+xx" > pattern = /^(?[^()]*(\(\g\)[^()]*)*)$/ You make my eyes bleed... Please don't use regular expressions for matching parentheses, it simply can't be done using regular expressions (well, .NET-"regular expressions" can, and perhaps there's some support for it in Oniguruma as well, but definitely not in the way you're doing it.). Use a context free grammar for that instead. You can use a tool like racc to do that. > puts "\nMuster: #{pattern.inspect}\nString: '#{orgstring}'" > if (res = orgstring.match(pattern)) then > puts "Match: '#{res}'" > else > puts "+++++ No Match" > end > ----------------------------------------------------------- > > produces the Error Message > > ----------------------------------------------------------- > never ending recursion: /^(?[^()]*(\(\g\)[^()]*)*)$/ > ----------------------------------------------------------- > > which is definitely wrong. No, it's definitely right. Your trying to match a inside a , right? That sounds like infinite recursion to me, nikolai -- Nikolai Weibull: now available free of charge at http://bitwi.se/! Born in Chicago, IL USA; currently residing in Gothenburg, Sweden. main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}