Show
Ignore:
Timestamp:
08/01/08 13:56:05 (4 months ago)
Author:
audreyt
Message:

* Import Pugs 6.2.13.11 from Hackage into our source tree.
* Highlights:

  • Much faster startup time
  • Slightly faster compilation time (mostly due to refactored Pugs.AST.Internals)
  • Portable-to-Win32 readline thanks to Haskeline
Files:
1 modified

Legend:

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

    r17044 r21673  
    1010import Pugs.Config 
    1111import Pugs.Prim.Code 
     12import Paths_Pugs 
    1213import qualified Data.Map as Map 
    1314import qualified Data.Array as Array 
     
    3233doMatch :: String -> VRule -> Eval VMatch 
    3334doMatch cs rule@MkRulePGE{ rxRule = ruleStr } = do 
    34     let pwd1 = getConfig "installsitelib" ++ "/auto/pugs/perl5/lib" 
    35         pwd2 = getConfig "sourcedir" ++ "/perl5/Pugs-Compiler-Rule/lib" 
    36     hasSrc <- io $ doesDirectoryExist pwd2 
    37     let pwd = if hasSrc then pwd2 else pwd1 
     35    pwd     <- io $ getDataFileName "blib6/pugs/perl5/lib" 
    3836    glob    <- askGlobal 
    3937    let syms = [ (cast $ v_name var, entry) 
     
    7068 
    7169doMatch csChars MkRulePCRE{ rxRegex = re } = do 
    72     rv <- io $ matchRegexWithPCRE re csBytes 0 
    73     if isNothing rv then return mkMatchFail else do 
    74     let ((fromBytes, lenBytes):subs) = Array.elems (fromJust rv) 
    75         substr str from len = take len (drop from str) 
    76         subsMatch = [ 
    77             VMatch $ if fBytes == -1 then mkMatchFail else mkMatchOk 
    78                 fChars (fChars + lChars) 
    79                 (substr csChars fChars lChars) 
    80                 [] Map.empty 
    81             | (fBytes, lBytes) <- subs 
    82             , let fChars = chars $ take fBytes csBytes 
    83             , let lChars = chars $ substr csBytes fBytes lBytes 
    84             ] 
    85         fromChars = chars $ take fromBytes csBytes 
    86         lenChars  = chars $ substr csBytes fromBytes lenBytes 
    87         chars = genericLength . decodeUTF8 
    88  
    89     return $ mkMatchOk fromChars (fromChars + lenChars) (substr csChars fromChars lenChars) subsMatch Map.empty 
     70    result <- io $ executePCRE re csBytes 
     71    case result of 
     72        Left{} -> return mkMatchFail 
     73        Right Nothing -> return mkMatchFail 
     74        Right (Just rv) -> do 
     75            let ((fromBytes, lenBytes):subs) = Array.elems rv 
     76                substr str from len = take len (drop from str) 
     77                subsMatch = [ 
     78                    VMatch $ if fBytes == -1 then mkMatchFail else mkMatchOk 
     79                        fChars (fChars + lChars) 
     80                        (substr csChars fChars lChars) 
     81                        [] Map.empty 
     82                    | (fBytes, lBytes) <- subs 
     83                    , let fChars = chars $ take fBytes csBytes 
     84                    , let lChars = chars $ substr csBytes fBytes lBytes 
     85                    ] 
     86                fromChars = chars $ take fromBytes csBytes 
     87                lenChars  = chars $ substr csBytes fromBytes lenBytes 
     88                chars = genericLength . decodeUTF8 
     89            return $ mkMatchOk fromChars (fromChars + lenChars) 
     90                (substr csChars fromChars lenChars) subsMatch Map.empty 
    9091    where 
    9192    csBytes = encodeUTF8 csChars