Re: StringBuilder Extension: IsQuotedBy

Barry Kelly <[email protected]> Fri, 15 Feb 2008 17:05:56 +0000
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
Peter Obiefuna <[email protected]> wrote:

> > Any single given regex terminates in a single state, "matched". A
> > tokenizer has multiple ending states, one for each token. This is the
> > key difference between most third-party regex libraries and the
> > requirements of people writing parsers for well-defined languages.
> >
> > -- Barry
> 
> I would expect a regex implementation to construct a FSM from it's
> expression string. Meaning that a "single given regex" could terminate in
> multiple states, each of which is a "matched" state.

Yes; but most third-party regex implementations don't distinguish
between matched states in the API, so in effect, all the matched states
are the same state. You'd need to extend a regex language to distinguish
between them.

In other words, for some regex R:

  R ::= 'a' | 'b' | 'c' .

We'd usually construct:

  s0 - start state
  s0 -'a'-> s1
  s0 -'b'-> s1
  s0 -'c'-> s1
  s1 - finish state

... and have slight difficulty in finding out which of a, b, or c we
saw.

> If it keeps hitting a
> matched state until the input buffer is finished, then, the string
> 'qualifies'. That, in my mind, is the difference between  a state engine and
> a collation engine like strcomp (never mind that you can illustrate FSM
> graphically by pointing to a final dot on paper). But I expect a Regex
> implementation to create a unique FSM from every input signature.

I don't understand your last sentence. The FSM is constructed for the
regex, not for the sentence to be matched.

Also, I don't see how this is relevant to why one wouldn't "still"
hand-write a DFA.

-- Barry

-- 
http://barrkel.blogspot.com/

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com