regexpr 0.1.7 → 0.2.0
raw patch · 5 files changed
+22/−4 lines, 5 files
Files
- Hidden/ParseRegexStr.hs +5/−2
- Hidden/SrcRegActList.hs +2/−0
- Hidden/TestMain.hs +9/−0
- Hidden/Tools.hs +5/−1
- regexpr.cabal +1/−1
Hidden/ParseRegexStr.hs view
@@ -16,7 +16,7 @@ import Hidden.ParseLib( runParse, spot, token, mplus, mzero, tokens, list, greedyList, optional, endOfInput ) import Control.Monad.State( liftM )-import Hidden.Tools ( isSymbol, (|||) )+import Hidden.Tools ( isSymbol, (|||), isBit7On ) import Data.Char ( isAlphaNum, isAlpha, isDigit, isSpace, toUpper, toLower ) import Hidden.SrcRegActList@@ -65,7 +65,8 @@ `mplus` do { token '\\'; c <- spot isSymbol; return $ Select (==c) } `mplus`- do { token '\\'; d1 <- spot isDigit; d2 <- greedyList $ spot isDigit;+ do { token '\\'; optional $ token '{'; d1 <- spot isDigit;+ d2 <- greedyList $ spot isDigit; optional $ token '}'; return $ BackReference $ read $ d1:d2 } `mplus` do { token '['; isNotNot <- optional (token '^') >>= return . null;@@ -97,6 +98,8 @@ parseBackSlashes backSlashesList `mplus` parseParenses parensesList+ `mplus`+ ( spot isBit7On >>= return . Select . (==) ) `mplus` do { tokens "(?#"; c <- list $ spot (/=')'); token ')'; return $ Comment c }
Hidden/SrcRegActList.hs view
@@ -34,6 +34,8 @@ , ('^', RegexOr [BeginningOfInput] [Still [Backword [Select (=='\n')]]]) , (',', Select (==',')) , (' ', Select (==' '))+ , ('<', Select (=='<'))+ , ('>', Select (=='>')) ] backSlashesList :: [ (Char, RegexAction) ]
Hidden/TestMain.hs view
@@ -152,4 +152,13 @@ , Just ( ("90af", ("", "g")), [] ) ~=? matchRegexPR "[[:xdigit:]]+" "90afg" , Just ( (" \n\t\r", ("", "a")), [] ) ~=? matchRegexPR "[[:blank:]]+" " \n\t\ra"+ , "<em>Ruby</b> and <b>Perl</em>" ~=?+ gsubRegexPR "<b>(.*)<\\/b>" "<em>\\1</em>" "<b>Ruby</b> and <b>Perl</b>"+ , "<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"+ , Just ( ("\227\129\130", ("", "")), [] )+ ~=?+ matchRegexPR "\227\129\130" "\227\129\130" ]
Hidden/Tools.hs view
@@ -16,10 +16,12 @@ , guardEqual , (|||) , (&&&)+, isBit7On ) where import Control.Monad.State( StateT(StateT, runStateT), lift, MonadTrans )-import Data.Char ( isAlphaNum, isSpace, isPrint )+import Data.Char ( isAlphaNum, isSpace, isPrint, ord )+import Data.Bits ( (.&.), shiftL ) import Control.Monad ( MonadPlus, guard ) isSymbol :: Char -> Bool@@ -51,3 +53,5 @@ (p1 ||| p2) x = p1 x || p2 x (p1 &&& p2) x = p1 x && p2 x +isBit7On :: Char -> Bool+isBit7On c = ord c .&. (shiftL 1 7) /= 0
regexpr.cabal view
@@ -1,5 +1,5 @@ Name: regexpr-Version: 0.1.7+Version: 0.2.0 License: GPL License-File: LICENSE Author: Yoshikuni Jujo <PAF01143@nifty.ne.jp>