Show
Ignore:
Timestamp:
05/12/05 21:45:17 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
4536
Message:

* split// now attaches the submatches themselves to the

resulting list.

Files:
1 modified

Legend:

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

    r3103 r3119  
    149149    return $ VBool $ x' `cmp` y' 
    150150 
    151 rxSplit :: VRule -> String -> Eval [String] 
     151rxSplit :: VRule -> String -> Eval [Val] 
    152152rxSplit _  [] = return [] 
    153153rxSplit rx str = do 
    154154    match <- str `doMatch` rx 
    155     if not (matchOk match) then return [str] else do 
     155    if not (matchOk match) then return [VStr str] else do 
    156156    if matchFrom match == matchTo match 
    157157        then do 
    158158            let (c:cs) = str 
    159159            rest <- rxSplit rx (cs) 
    160             return ([c]:rest) 
     160            return (VStr [c]:rest) 
    161161        else do 
    162162            let before = genericTake (matchFrom match) str 
    163163                after  = genericDrop (matchTo match) str 
    164164            rest <- rxSplit rx after 
    165             strs <- mapM fromVal (matchSubPos match) 
    166             return $ (before:concat strs) ++ rest 
     165            return $ (VStr before:matchSubPos match) ++ rest