Changeset 7861
- Timestamp:
- 11/05/05 23:47:32 (3 years ago)
- Files:
-
- 1 modified
-
src/Pugs/Prim/Match.hs (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Prim/Match.hs
r7854 r7861 15 15 16 16 doMatch :: String -> VRule -> Eval VMatch 17 -- Work around PGE bug on Parrot 0.3.1 -- empty rule matches automatically 18 doMatch _ MkRulePGE{ rxRule = "" } = return $ mkMatchOk 0 0 "" [] Map.empty 17 19 doMatch cs MkRulePGE{ rxRule = re } = do 18 20 let pwd1 = getConfig "installarchlib" ++ "/CORE/pugs/pge" … … 153 155 where 154 156 hasSubpatterns = case rx of 155 MkRulePGE{} -> True -- bogus157 MkRulePGE{} -> True -- XXX bogus - use <p6rule> to parse itself 156 158 MkRulePCRE{rxNumSubs=n} -> not (n == 0) 157 159 matchOnce :: String -> Eval [Val] … … 159 161 match <- str `doMatch` rx 160 162 if not (matchOk match) then return [] else do 161 rest <- matchOnce (genericDrop (matchTo match) str) 162 return $ if hasSubpatterns 163 then (matchSubPos match) ++ rest 164 else (VMatch match):rest 163 let ret x = return $ if hasSubpatterns 164 then (matchSubPos match) ++ x 165 else (VMatch match):x 166 case (matchTo match, matchFrom match) of 167 (0, 0) -> if null str then ret [] else do 168 rest <- matchOnce (tail str) 169 ret rest 170 (to, _) -> do 171 rest <- matchOnce (genericDrop to str) 172 ret rest 165 173 166 174 op2Match x (VRule rx) = do … … 210 218 then do 211 219 let (c:cs) = str 212 rest <- rxSplit rx (cs)220 rest <- rxSplit rx cs 213 221 return (VStr [c]:rest) 214 222 else do
