develooper Front page | perl.perl5.porters | Postings from September 2011

Re: [perl #92898] (*THEN) broken inside condition subpattern

Thread Previous | Thread Next
From:
Philip Hazel
Date:
September 28, 2011 03:11
Subject:
Re: [perl #92898] (*THEN) broken inside condition subpattern
Message ID:
alpine.LNX.2.00.1109271203280.30054@quercite.quercite.com
On Mon, 26 Sep 2011, Father Chrysostomos via RT wrote:

> *at the current starting position*
> 
> (*THEN) acts like (*COMMIT) in the example given above.

Aha.

Since we are quoting "man perlre", here's another bit of confusion:

   "(?PARNO)" "(?-PARNO)" "(?+PARNO)" "(?R)" "(?0)"
              Similar to "(??{ code })" except it does not involve
              compiling any code, instead it treats the contents of a
              capture buffer as an independent pattern that must match at
              the current position. 

Consider this pattern (ignore white space):

  ^.*? (?1) c (?(DEFINE) (a(*THEN)b) )
  
When I read "an independent pattern", it suggests to me that the effect 
of (*THEN) is confined to that independent pattern. However, experiment 
with Perl shows that I am wrong here as well. The pattern as it stands
does not match "aabc", but if |(*F) is added after b, it does. 

As it happens, PCRE processes recursions/subroutines differently to
Perl, or perhaps I should say that the other way round, since PCRE had
them first. :-) So another difference probably doesn't matter much.

However, I'm still thinking about this whole issue with regard to PCRE
implementation. It tries to resolve where (*THEN) should back up to at
compile time, but looking at the example above, it seems to me that it
can only be done dynamically, at run time.

Regards,
Philip

-- 
Philip Hazel

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