Show
Ignore:
Timestamp:
08/07/05 20:12:10 (3 years ago)
Author:
putter
Message:

PCRE :global rules, without a subpattern, now return the correct match array. my @a = 'aaa' rx:perl5:g/a/; +@a #=> 3, not 0. PGE rules are not fixed, awaiting a way to determine if they contain a subpattern. Match .from and .to still incorrect. The patch is a bit messy. This would all be better handled by p6-side analysis and implementation of :global.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/Match.hs

    r6010 r6109  
    144144            else return (VList rv) 
    145145    where 
     146    hasSubpatterns = case rx of 
     147        MkRulePGE{}             -> True -- bogus 
     148        MkRulePCRE{rxNumSubs=n} -> not (n == 0) 
    146149    matchOnce :: String -> Eval [Val] 
    147150    matchOnce str = do 
     
    149152        if not (matchOk match) then return [] else do 
    150153        rest <- matchOnce (genericDrop (matchTo match) str) 
    151         return $ matchSubPos match ++ rest 
     154        return $ if hasSubpatterns 
     155                 then (matchSubPos match) ++ rest 
     156                 else (VMatch match):rest 
    152157 
    153158op2Match x (VRule rx) = do