| 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 |