Re: Leftmost longest match with DFA search

Stefan Monnier <monnier@iro.umontreal.ca>
Tue, 13 May 2008 04:51:39 -0400

          From comp.compilers

Related articles
Leftmost longest match with DFA search monnier@iro.umontreal.ca (Stefan Monnier) (2008-05-10)
Re: Leftmost longest match with DFA search daniel2villeneuve@videotron.ca (Daniel Villeneuve) (2008-05-11)
Re: Leftmost longest match with DFA search rsc@swtch.com (Russ Cox) (2008-05-12)
Re: Leftmost longest match with DFA search monnier@iro.umontreal.ca (Stefan Monnier) (2008-05-13)
Re: Leftmost longest match with DFA search monnier@iro.umontreal.ca (Stefan Monnier) (2008-05-13)
Re: Leftmost longest match with DFA search Danny.Dube@ift.ulaval.ca (2008-05-13)
Re: Leftmost longest match with DFA search rsc@swtch.com (Russ Cox) (2008-05-14)
Re: Leftmost longest match with DFA search Danny.Dube@ift.remove.ulaval.remove.ca (2008-05-15)
| List of all articles for this month |

From: Stefan Monnier <monnier@iro.umontreal.ca>
Newsgroups: comp.compilers
Date: Tue, 13 May 2008 04:51:39 -0400
Organization: UseNetServer.com
References: 08-05-026 08-05-029
Keywords: lex, DFA
Posted-Date: 14 May 2008 11:55:09 EDT

>> Can someone point me to articles that discuss various ways to get the
>> leftmost longest match when implementing regexp search using a DFA?
>>
>> The "obvious" solution of turning the problem "search for RE" into the
>> problem "match .*RE" (where I use "match" here to mean "anchored
>> search") only gives you the leftmost shortest match.
> [snip]
>> Stefan


> I've used the approach to compile a DFA for the reverse RE, say ER, and
> first match .*ER on the reverse text to find the leftmost anchor point.
> Then match RE from that point to find the longest span.


Interesting. But doesn't it basically force you to scan the complete text?
That can be impractical.




                Stefan


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.