On Sunday 25 November 2001 11:09 pm, Brent Dax wrote:
> Not exactly.
>
> C:\perl572\perl\win32>perl -mre=debug -e "print 'xaaabccccx'=~/a+bc+/"
> ....
> Guessing start of match, REx `a+bc+' against `xaaabccccx'...
> Found floating substr `abc' at offset 3...
> Found anchored substr `a' at offset 1...
> Starting position does not contradict /^/m...
> Guessed: match at offset 1
> Matching REx `a+bc+' against `aaabccccx'
>   Setting an EVAL scope, savestack=3
>    1 <x> <aaabccccx>      |  1:  PLUS
>                            EXACT <a> can match 3 times out of 32767...

There's the a+.

>   Setting an EVAL scope, savestack=3
>    4 <xaaa> <bccccx>      |  4:    EXACT <b>

The b.

>    5 <xaaab> <ccccx>      |  6:    PLUS
>                            EXACT <c> can match 4 times out of 32767...

And the c.

>   Setting an EVAL scope, savestack=3
>    9 <xaaabcccc> <x>      |  9:      END
> Match successful!
> Freeing REx: `a+bc+'
> 1
>
> It finds the 'a', then the 'abc', then tries the match.  My mistake.
> Still, that's a hell of a lot more intelligent than just 'proceeding
> dumbly left-to-right'.

It shows up better if you throw in some failures first.

Whammo # perl -Mre=debug -e '$_ = 
"ptertdoidoigdoidgeo5h45624gnrekgnreotgh4o564otngertgoiaaaaaaaaabbbbabccccccabc"; 
/a+bc+/'
Freeing REx: `,'
Compiling REx `a+bc+'
size 9 first at 2
   1: PLUS(4)
   2:   EXACT <a>(0)
   4: EXACT <b>(6)
   6: PLUS(9)
   7:   EXACT <c>(0)
   9: END(0)
anchored `a' at 0 floating `abc' at 0..2147483647 (checking floating) plus 
minlen 3
Guessing start of match, REx `a+bc+' against 
`ptertdoidoigdoidgeo5h45624gnrekgnreotgh4o564otngertgoiaaaaaa...'...
Found floating substr `abc' at offset 67...

Here it looks for 'abc', and finds a case, but it never comes into play.  
(Okay, in truth the smarts here come into play into determining whether the 
string can match at all.  If it never finds 'abc', it can fail immediately.  
Which is a little smarter than dumb.  But once it passes this, it proceeds 
quite dumb.  So the actual matching of the string isn't optimized.  So 
comparative successful matches can probably still be made.  Perl 5 will flag 
failures faster.)

Found anchored substr `a' at offset 54...

It goes back and looks for the first a.

Starting position does not contradict /^/m...
Guessed: match at offset 54
Matching REx `a+bc+' against `aaaaaaaaabbbbabccccccabc'
  Setting an EVAL scope, savestack=3
  54 <rtgoi> <aaaaaaa>    |  1:  PLUS
                           EXACT <a> can match 9 times out of 32767...  
Setting an EVAL scope, savestack=3
  63 <aaaaa> <bbbbabc>    |  4:    EXACT <b>
  64 <aaaab> <bbbabcc>    |  6:    PLUS
                           EXACT <c> can match 0 times out of 32767...  
Setting an EVAL scope, savestack=3
                              failed...
                            failed...
  Setting an EVAL scope, savestack=3
  67 <abbbb> <abccccc>    |  1:  PLUS
                           EXACT <a> can match 1 times out of 32767...  
Setting an EVAL scope, savestack=3
  68 <bbbba> <bcccccc>    |  4:    EXACT <b>
  69 <bbbab> <cccccca>    |  6:    PLUS
                           EXACT <c> can match 6 times out of 32767...  
Setting an EVAL scope, savestack=3
  75 <babcccccc> <abc>    |  9:      END
Match successful!
Freeing REx: `a+bc+'

And proceeds, dumbly, left to right.  

> "Nothing important happened today."
>     --George III of England's diary entry for 4-Jul-1776

Nothing important did happen.

-- 
Bryan C. Warnock
[EMAIL PROTECTED]

Reply via email to