packages feed

regexpr 0.3.3 → 0.3.4

raw patch · 4 files changed

+19/−15 lines, 4 files

Files

Hidden/ParseRegexStr.hs view
@@ -14,16 +14,17 @@ 			     setMode, setModes, getModes, 			     isModeI, isModeM, isModeX ) import Text.ParserCombinators.MTLParse-                           ( runParse, spot, spotBack, token, tokens, mzero, mplus,+                           ( runParse, spot, token, tokens, mzero, mplus,                              still, parseNot, endOfInput, MonadParse, 			     MonadPlus,-                             list, greedyNeList, optional )+                             list, neList, greedyNeList, optional ) import Hidden.Tools	   ( isSymbol, ignoreCase, skipRet, (>..>), ifM,                              applyIf, (&&&), headOrErr, modifyFst ) import Data.Char	   ( isAlphaNum, isDigit, isSpace ) import Data.Ix             ( inRange ) import Hidden.SrcRegActList( selfTest, oneCharList, backSlashesList, plusesList,                              parensesList, charClassList )+import Control.Applicative ((<$>))  parseRegexStr :: String -> [RegexAction] parseRegexStr src =@@ -45,7 +46,7 @@ parseQuantifier :: RegexSrcParser (RegexAction -> RegexAction) parseQuantifier   = do { token '{';-         mn <- list $ spot isDigit;+         mn <- neList $ spot isDigit;          mx <- do { cma <- optional $ token ','; 	            case cma of 		         "" -> return Nothing@@ -64,14 +65,13 @@     ( isModeI >>= \ic ->        spot selfTest >>= return . Select . applyIf ic ignoreCase . (==) )     `mplus`-    parseOpenBrace `mplus` parseCloseBrace+    parseOpenBrace     `mplus`     ( flip (ifM isModeM) mzero $ token '.' >> return (Select $ const True) )     `mplus`     ( token '\\' >> spot isSymbol >>= return . Select . (==) )     `mplus`-    ( token '\\' >> optional (token '{') >> greedyNeList (spot isDigit) >>=-      skipRet (optional $token '}') >>= return . BackReference . read )+    parseBackReference     `mplus`     ( token '[' >> optional (token '^') >>= return . not . null >>= \isNot ->       parseCharList >>= skipRet (token ']') >>=@@ -150,11 +150,15 @@ concatMapParse f = foldr mplus mzero . map f  parseOpenBrace :: RegexSrcParser RegexAction-parseOpenBrace = do ret <- token '{'-                    still $ parseNot () $ spot isDigit+parseOpenBrace = do still $ parseNot () $ parseQuantifier+                    still $ parseNot () $ parseBackReference+                    ret <- token '{'                     return $ Select (==ret) -parseCloseBrace :: RegexSrcParser RegexAction-parseCloseBrace = do still $ parseNot () $ spotBack isDigit-                     ret <- token '}'-		     return $ Select (==ret)+parseBackReference :: RegexSrcParser RegexAction+parseBackReference = do+  brace <- null <$> (optional $ token '{')+  token '\\'+  dgt <- greedyNeList (spot isDigit)+  if brace then return ' ' else token '}'+  return $ BackReference $ read dgt
Hidden/SrcRegActList.hs view
@@ -19,7 +19,7 @@  selfTest :: Char -> Bool selfTest-  = flip elem "\b\n\f\r\t !\"#%&',-/:;<=>@]_'~" ||| isAlphaNum ||| isBit7On+  = flip elem "\b\n\f\r\t !\"#%&',-/:;<=>@]_'~}" ||| isAlphaNum ||| isBit7On  plusesList :: [ (String, RegexAction -> RegexAction) ] plusesList = [
Hidden/TestMain.hs view
@@ -160,7 +160,7 @@  , "<em>Ruby</em> and <em>Perl</em>"    ~=?      gsubRegexPR "<b>(.*?)<\\/b>" "<em>\\1</em>" "<b>Ruby</b> and <b>Perl</b>"  , Just ( ("abab0", ("", "")), [(1,"ab")] )-                                        ~=? matchRegexPR "(ab)\\{1}0" "abab0"+                                        ~=? matchRegexPR "(ab){\\1}0" "abab0"  , Just ( ("\227\129\130", ("", "")), [] )                                         ~=?      matchRegexPR "\227\129\130" "\227\129\130"
regexpr.cabal view
@@ -1,5 +1,5 @@ Name:		regexpr-Version:	0.3.3+Version:	0.3.4 License:	LGPL License-File:	LICENSE Author:		Yoshikuni Jujo <PAF01143@nifty.ne.jp>