develooper Front page | perl.perl6.language.regex | Postings from January 2001

Re: Exposing regexp engine & compiled regexp's

Thread Previous | Thread Next
From:
Damian Conway
Date:
January 6, 2001 13:08
Subject:
Re: Exposing regexp engine & compiled regexp's
Message ID:
200101062108.IAA22896@indy05.csse.monash.edu.au
   
   > 1.  I think it should be possible to have ``incomplete matches''.
   > 
   >     Regexp's are interpreted by a NFA, that is a state machine.
   >     I think it would be nice if, when I try to match a regexp against
   >     a string, and the string ends before the regexp matches, it
   >     would be possible to find out in which state the NFA has stopped,
   >     and it would also be possible to start another match from
   >     that state on.

I once wrote a C++-based regex engine (much simpler than Perl's!)
just like this.

Knowing why a regex failed *is* invaluable when matching regexes
against file streams, but there are more possibilities than you 
mentioned:

             "Failed"        Did not match because of illegal transition

             "Short"         Did not match: did not reach acceptor state

             "Exact"         Matched and finished in an acceptor state

             "Long"          Passed through an acceptor state, continued to
			     match, but did not finish in an acceptor state

             "LongFailed"    Passed through an acceptor state, continued to
			     match, but then found an illegal transition

Ultimately, I decided that what was needed wasn't insight into the cause
of failure, but rather the chance to provide more data to "feed" the
engine so it doesn't have to fail "Short" or "Long". That's why I
proposed RFC 93 (http://dev.perl.org/rfc/93.html) instead of a mechanism
such as you have suggested.

Damian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About