> 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