Show
Ignore:
Timestamp:
05/10/05 21:29:10 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
4498
Message:

* named rules and subrule support.

Files:
1 modified

Legend:

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

    r2942 r2944  
    2020    hasSrc <- liftIO $ doesDirectoryExist pwd2 
    2121    let pwd = if hasSrc then pwd2 else pwd1 
    22     pge <- liftIO $ evalPGE pwd (encodeUTF8 cs) (encodeUTF8 re) 
     22    glob    <- askGlobal 
     23    let syms = [ (name, tvar) | (('<':name), [(_, tvar)]) <- padToList glob ] 
     24    subrules <- forM syms $ \(name, tvar) -> do 
     25        ref  <- liftSTM $ readTVar tvar 
     26        (VRule rule) <- fromVal =<< readRef ref 
     27        return (name, rxRule rule) 
     28    pge <- liftIO $ evalPGE pwd (encodeUTF8 cs) (encodeUTF8 re) subrules 
    2329    rv  <- tryIO Nothing $ fmap Just (readIO $ decodeUTF8 pge)  
    2430    let matchToVal PGE_Fail = VMatch mkMatchFail 
     
    3238    case rv of 
    3339        Just m  -> fromVal (matchToVal m) 
    34         Nothing -> fail ("Cannot parse PGE: " ++ pge) 
     40        Nothing -> do 
     41            liftIO $ putStrLn ("*** Cannot parse PGE: " ++ re ++ "\n*** Error: " ++ pge) 
     42            return mkMatchFail 
    3543 
    3644doMatch cs MkRulePCRE{ rxRegex = re } = do