packages feed

regexchar 0.9.0.8 → 0.9.0.9

raw patch · 15 files changed

+182/−162 lines, 15 filesdep −haskell98dep ~regexdotdep ~toolshed

Dependencies removed: haskell98

Dependency ranges changed: regexdot, toolshed

Files

changelog view
@@ -42,3 +42,11 @@ 	* Used new module "ToolShed.Pair" from package toolshed-0.12.0.0. 	* Relocated modules "Grecce.Assert", "Grecce.Performance" and "Grecce.QC", into new layer "Test", in module-hierarchy. 	* Guarded 'eager-blackholing' flag in cabal file.+0.9.0.9+	* Recoded "RegExChar.RegExOptsChar" to the interface "Data.Array.IArray.IArray", rather than the data-type "Data.Array.Array".+	* Replaced '(+ 1)' and '(- 1)' with the faster calls 'succ' and 'pred', in "RegExChar.RegExOptsChar", "Grecce.Test.Performance.ExtendedRegExTestsPositive" and "Grecce.Grep".+	* Used 'Paths_regexchar.version' in 'Main', rather than hard-coding it.+	* Reacted to new module-hierarchy and addition of method 'ToolShed.SelfValidate.getErrors', in toolshed-0.13.0.0, and used it to improved error-reporting in @instance Read RegExChar.ExtendedRegExChar.ExtendedRegExChar@.+	* Replaced use of "Control.Monad" in "RegExChar.MetaChar" and "RegExChar.ExtendedRegExChar", with "Control.Applicative".+	* Replaced "System" with "System.Environment" and "System.Exit".+	* Removed dependency on "haskell98".
makefile view
@@ -1,18 +1,18 @@ # Copyright (C) 2010 Dr. Alistair Ward-# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version.-# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the # GNU General Public License for more details.-# +# # You should have received a copy of the GNU General Public License # along with this program.  If not, see <http://www.gnu.org/licenses/>.- + .PHONY: all build check clean clobber configure copy deb haddock help hlint install lintian prof rpm rpmlint sdist  all: install@@ -22,7 +22,7 @@ 	runhaskell Setup.hs $@ $$CABAL_INSTALL_OPTIONS  prof:-	CABAL_CONFIGURE_OPTIONS="--enable-library-profiling --enable-executable-profiling $$CABAL_CONFIGURE_OPTIONS" make install+	CABAL_CONFIGURE_OPTIONS="--enable-library-profiling --enable-executable-profiling $$CABAL_CONFIGURE_OPTIONS" make build  copy: build 	@[ -z "$$CABAL_COPY_OPTIONS" ] || echo "INFO: CABAL_COPY_OPTIONS='$$CABAL_COPY_OPTIONS'"@@ -40,7 +40,7 @@ 	PATH=~/.cabal/bin:$$PATH runhaskell Setup.hs $@ --hyperlink-source --executables	#Amend path to find 'HsColour', as required for 'hyperlink-source'.  hlint:-	@$@ src/+	@$@ -i 'Use ||' src/  sdist: configure 	runhaskell Setup.hs $@@@ -70,7 +70,7 @@ clean: 	runhaskell Setup.hs $@ 	rm -rf 'debian/usr/' 'debian/DEBIAN/md5sums'-	find src -type f \( -name '*.o' -o -name '*.hi' \) -delete+	find src -type f \( -name '*.hc' -o -name '*.hcr' -o -name '*.hi' -o -name '*.o' \) -delete  clobber: clean 	rm -f -- *.rpm *.deb
regexchar.cabal view
@@ -1,6 +1,6 @@ --Package-properties Name:			regexchar-Version:		0.9.0.8+Version:		0.9.0.9 Cabal-Version:		>= 1.6 Copyright:		(C) 2010 Dr. Alistair Ward License:		GPL@@ -38,13 +38,16 @@     Build-depends:         base == 4.*,         containers,-        haskell98,         parsec == 3.*,-        regexdot == 0.10.*,-        toolshed >= 0.12+        regexdot == 0.11.*,+        toolshed == 0.13.*      GHC-options:	-Wall-    GHC-prof-options:	-prof -auto-all -caf-all++    if impl(ghc >= 7.4.1)+        GHC-prof-options:	-prof -fprof-auto -fprof-cafs+    else+        GHC-prof-options:	-prof -auto-all -caf-all      if impl(ghc >= 7.0) && flag(llvm)         GHC-options:	-fllvm
regexchar.spec view
@@ -6,9 +6,9 @@ %define _docdir		%prefix/share/doc/%package %define _mandir		%prefix/share/man -Summary: 	A re-implementation of egrep, using a specialisation of a polymorphic regex-engine.+Summary:	A re-implementation of egrep, using a specialisation of a polymorphic regex-engine. Name:		regexchar-Version:	0.9.0.8+Version:	0.9.0.9 Release:	1 License:	GPLv3 #From '/usr/share/doc/packages/rpm/GROUPS'.
src/Grecce/CommandOptions.hs view
@@ -48,8 +48,8 @@ import qualified	RegExChar.ExtendedRegExChar	as ExtendedRegExChar import qualified	RegExDot.CompilationOptions	as CompilationOptions import qualified	RegExDot.ExecutionOptions	as ExecutionOptions-import qualified	ToolShed.Defaultable		as Defaultable-import qualified	ToolShed.Options		as Options+import qualified	ToolShed.Defaultable+import qualified	ToolShed.Options  -- | The set of command-line options; based on those provided by /egrep/. data CommandOptions	= MkCommandOptions {@@ -67,8 +67,8 @@ -- | An arbitrary function which transforms the supplied 'ExecutionOptions.ExecutionOptions'. type Transformer	= CommandOptions -> CommandOptions -instance Defaultable.Defaultable CommandOptions	where-	defaultValue	= Options.blankValue {+instance ToolShed.Defaultable.Defaultable CommandOptions	where+	defaultValue	= ToolShed.Options.blankValue { 		countMatches		= False, 		extendedRegExChar	= Nothing, 		invertMatch		= False,@@ -76,11 +76,11 @@ 		listFilesWithMatches	= False, 		listFilesWithoutMatch	= False, 		verbose			= False,-		compilationOptions	= Defaultable.defaultValue,-		executionOptions	= Defaultable.defaultValue+		compilationOptions	= ToolShed.Defaultable.defaultValue,+		executionOptions	= ToolShed.Defaultable.defaultValue 	} -instance Options.Options CommandOptions	where+instance ToolShed.Options.Options CommandOptions	where 	blankValue	= MkCommandOptions { 		countMatches		= undefined, 		extendedRegExChar	= undefined,
src/Grecce/Grep.hs view
@@ -21,7 +21,7 @@  [@DESCRIPTION@]	Performs the match-operation on the specified file-list, using the user's command-line options. -} -module Grecce.Grep (+module Grecce.Grep( -- * Types --	LineNumber, --	Matches,@@ -37,12 +37,12 @@ import qualified	Data.List import qualified	Grecce.CommandOptions		as CommandOptions import qualified	RegExChar.ExtendedRegExChar	as ExtendedRegExChar+import			RegExChar.ExtendedRegExChar((+~), (=~)) import qualified	RegExDot.RegEx			as RegEx import qualified	RegExDot.RegExOpts		as RegExOpts import qualified	RegExDot.Result			as Result-import qualified	System+import qualified	System.Exit import qualified	System.IO-import			RegExChar.ExtendedRegExChar	as ExtendedRegExChar((+~), (=~))  #if MIN_VERSION_parallel(3,0,0) import qualified	Control.Parallel.Strategies@@ -52,44 +52,44 @@ type Matches	= Int  -- | Creates a 'RegExOpts.RegExOpts' record from 'CommandOptions.CommandOptions', and uses it to filter the lines read from the list of input-data files, the result of which is then printed.-grep ::-	CommandOptions.CommandOptions	-- ^ The match-criteria, which may include the name of the file on which to operate.-	-> [String]			-- ^ A supplementary list of files on which to operate-	-> IO ()			-- ^ Nothing is returned, since the result is printed.+grep+	:: CommandOptions.CommandOptions	-- ^ The match-criteria, which may include the name of the file on which to operate.+	-> [String]				-- ^ A supplementary list of files on which to operate+	-> IO ()				-- ^ Nothing is returned, since the result is printed. grep commandOptions nonOptions {-  The algorithm depends fundamentally on whether the data comes from 'stdin' or from file.  This is because of the requirement, in the former case, to deliver instantaneous feedback.  This forces us to print matches as they're found, rather than batching them for return to the caller to print.- If we COULD return 'IO [String]', then 'matchFilterStdIn' could be called instead of 'grep' when (filename == "-"); annoyingly, it just doesn't work.+ If we COULD return 'IO [String]', then 'matchFilterStdIn' could be called instead of 'grep' when (fileName == "-"); annoyingly, it just doesn't work. -} 	| any ($ fileNames) [null, all (== "-")]	= let-		matchFilterStdIn :: LineNumber -> Matches -> IO System.ExitCode+		matchFilterStdIn :: LineNumber -> Matches -> IO System.Exit.ExitCode 		matchFilterStdIn lineNumber matches	= {-#SCC "matchFilterStdIn" #-} do 			isEOF	<- System.IO.isEOF  			if isEOF 				then if listFilesWithMatches-					then return {-to IO-monad-} $ System.ExitFailure 1	--No match has been found, otherwise we'd have exited earlier.+					then return {-to IO-monad-} $ System.Exit.ExitFailure 1	--No match has been found, otherwise we'd have exited earlier. 					else if listFilesWithoutMatch-						then putStrLn dummyFileName	>> return {-to IO-monad-} System.ExitSuccess+						then putStrLn dummyFileName	>> return {-to IO-monad-} System.Exit.ExitSuccess 						else do 							Control.Monad.when countMatches $ print matches  							return {-to IO-monad-} $ if matches == 0-								then System.ExitFailure 1-								else System.ExitSuccess+								then System.Exit.ExitFailure 1+								else System.Exit.ExitSuccess 				else {-not EOF-} do 					line	<- getLine	--Process line-at-a-time, to provide instant feedback.  					let 						lineNumber' :: LineNumber-						lineNumber'	= lineNumber + 1+						lineNumber'	= succ lineNumber -						onSuccess :: String -> IO System.ExitCode+						onSuccess :: String -> IO System.Exit.ExitCode 						onSuccess line'-							| listFilesWithMatches	= putStrLn dummyFileName	>> return {-to IO-monad-} System.ExitSuccess-							| listFilesWithoutMatch	= return {-to IO-monad-} $ System.ExitFailure 1+							| listFilesWithMatches	= putStrLn dummyFileName	>> return {-to IO-monad-} System.Exit.ExitSuccess+							| listFilesWithoutMatch	= return {-to IO-monad-} $ System.Exit.ExitFailure 1 							| otherwise		= do 								Control.Monad.unless countMatches . putStrLn $ ( 									if prependLineNumbers@@ -97,9 +97,9 @@ 										else id 								 ) line' -								matchFilterStdIn lineNumber' $ matches + 1	--Recurse.+								matchFilterStdIn lineNumber' $ succ matches	--Recurse. -						onFailure, onMismatch :: IO System.ExitCode+						onFailure, onMismatch :: IO System.Exit.ExitCode 						onFailure	= matchFilterStdIn lineNumber' matches	--Recurse 						onMismatch 							| invertMatch	= onSuccess line@@ -122,7 +122,7 @@ 			where 				dummyFileName :: String 				dummyFileName	= "<standard input>"-	in matchFilterStdIn 0 0 >>= System.exitWith+	in matchFilterStdIn 0 0 >>= System.Exit.exitWith 	| otherwise {-file-names provided-}	= let 		findMatch :: String -> RegEx.Result Char 		findMatch	= (+~ regExOpts)@@ -175,9 +175,9 @@  		mapM_ putStrLn results -		System.exitWith $ if null results-			then System.ExitFailure 1-			else System.ExitSuccess+		System.Exit.exitWith $ if null results+			then System.Exit.ExitFailure 1+			else System.Exit.ExitSuccess 	where 		countMatches, invertMatch, prependLineNumbers, listFilesWithMatches, listFilesWithoutMatch, verbose :: Bool 		[countMatches, invertMatch, prependLineNumbers, listFilesWithMatches, listFilesWithoutMatch, verbose]	= ($ commandOptions) `map` [
src/Grecce/Test/Assert/RegExOptsChar.hs view
@@ -62,7 +62,7 @@ -- | Filters a list of 'Test's, & returns a sub-set. type TestFilter		= [Test] -> [Test] --- | 'True' if the specified 'ExtendedRegExChar.InputData', is a member of the set defined by the polymorphic 'Text.Regex.Base.RegexLike.RegexLike' parameter.+-- | True if the specified 'ExtendedRegExChar.InputData', is a member of the set defined by the polymorphic 'Text.Regex.Base.RegexLike.RegexLike' parameter. isMatch :: RegexLike.RegexLike r ExtendedRegExChar.InputData => r -> TestDataAndResult -> Bool isMatch regex (inputData, matchSpanList)	= RegexLike.matchOnce regex inputData == Just (RegExOptsChar.toZeroIndexedArray matchSpanList) 
src/Grecce/Test/Performance/ExtendedRegEx.hs view
@@ -62,8 +62,8 @@ import qualified	RegExDot.RegEx						as RegEx import qualified	RegExDot.RegExOpts					as RegExOpts import qualified	Text.Regex.Posix-import qualified	ToolShed.Defaultable					as Defaultable-import qualified	ToolShed.TimePure					as TimePure+import qualified	ToolShed.Defaultable+import qualified	ToolShed.System.TimePure  solitary :: Bool solitary	= True	--Currently required because of the disastrous performance of "Text.Regex.Posix" on 'Test.Performance.ExtendedRegExTestsPositive.OVERLAPPING_ALTERNATIVES'.@@ -87,7 +87,7 @@ 		cpuSecondsFor :: GenerateAndRunTest 		cpuSecondsFor testGenerator	= ( 			\(inputData, (isMismatch, extendedRegExCharString))	-> (,) extendedRegExCharString <$> mapM (-				TimePure.getCPUSeconds . ($ inputData) . (show .)+				ToolShed.System.TimePure.getCPUSeconds . ($ inputData) . (show .) 			 ) [ 				isMismatch, 				if solitary@@ -98,7 +98,7 @@ 			( 				\extendedRegEx -> ( 					RegEx./~ RegExOpts.MkRegExOpts {	--CAVEAT: <http://hackage.haskell.org/trac/haskell-prime/wiki/QualifiedOperators>.-						RegExOpts.compilationOptions	= Defaultable.defaultValue,+						RegExOpts.compilationOptions	= ToolShed.Defaultable.defaultValue, 						RegExOpts.executionOptions	= executionOptions, 						RegExOpts.regEx			= extendedRegEx 					}@@ -115,7 +115,7 @@ 		cpuSecondsFor :: GenerateAndRunTest 		cpuSecondsFor testGenerator	= ( 			\(inputData, (showMatch, extendedRegExCharString))	-> (,) extendedRegExCharString <$> (-				(TimePure.getCPUSeconds . ($ inputData)) `mapM` [+				(ToolShed.System.TimePure.getCPUSeconds . ($ inputData)) `mapM` [ 					showMatch, 					if ExecutionOptions.requireMatchList executionOptions 						then if solitary@@ -132,7 +132,7 @@ 				\extendedRegEx -> let 					regExOpts :: RegExOpts.RegExOpts (RegEx.ExtendedRegEx Char) 					regExOpts	= RegExOpts.MkRegExOpts {-						RegExOpts.compilationOptions	= Defaultable.defaultValue,+						RegExOpts.compilationOptions	= ToolShed.Defaultable.defaultValue, 						RegExOpts.executionOptions	= executionOptions, 						RegExOpts.regEx			= extendedRegEx 					} --Similar to 'RegexLike.makeRegexOpts', but without the requirement to read the regex.
src/Grecce/Test/Performance/ExtendedRegExTestsPositive.hs view
@@ -268,7 +268,7 @@ 				UNBRIDLED_GREED, 				\complexity	-> let 					complexity' :: Test.Performance.ExtendedRegExTest.TestComplexity-					complexity'	= 1 + complexity+					complexity'	= succ complexity  					testSet :: String 					testSet	= take complexity' . filter Data.Char.isAlphaNum $ filter Data.Char.isAscii [minBound .. maxBound]@@ -326,4 +326,4 @@ 	* <http://mathworld.wolfram.com/TriangularNumber.html>. -} triangularSeries :: Integral i => i -> i-triangularSeries i	= i * (i + 1) `div` 2+triangularSeries i	= i * succ i `div` 2
src/Grecce/Test/QC/ExtendedRegExChar.hs view
@@ -51,11 +51,11 @@ import qualified	RegExDot.RegExOpts			as RegExOpts import qualified	RegExDot.Repeatable			as Repeatable import qualified	RegExDot.Result				as Result-import qualified	Test.QuickCheck-import qualified	ToolShed.SelfValidate			as SelfValidate import			RegExDot.DSL((-:), (?:), (+:), (<~>)) import			RegExDot.RegEx((+~))+import qualified	Test.QuickCheck import			Test.QuickCheck((==>))+import qualified	ToolShed.SelfValidate  -- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'. newtype AlternativesChar	= MkAlternativesChar (RegEx.Alternatives Char) deriving (Eq, Read, Show)@@ -64,8 +64,8 @@ deconstructAlternativesChar :: AlternativesChar -> RegEx.Alternatives Char deconstructAlternativesChar (MkAlternativesChar a)	= a -instance SelfValidate.SelfValidator AlternativesChar where-	isValid	= SelfValidate.isValid . deconstructAlternativesChar+instance ToolShed.SelfValidate.SelfValidator AlternativesChar where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstructAlternativesChar  instance Consumer.Consumer AlternativesChar where 	consumptionProfile	= Consumer.consumptionProfile . deconstructAlternativesChar@@ -86,8 +86,8 @@ deconstructPatternChar :: PatternChar -> RegEx.Pattern Char deconstructPatternChar (MkPatternChar pattern)	= pattern -instance SelfValidate.SelfValidator PatternChar	where-	isValid	= SelfValidate.isValid . deconstructPatternChar+instance ToolShed.SelfValidate.SelfValidator PatternChar	where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstructPatternChar  instance Consumer.Consumer PatternChar	where 	consumptionProfile	= Consumer.consumptionProfile . deconstructPatternChar@@ -109,8 +109,8 @@ deconstructRepeatablePatternChar :: RepeatablePatternChar -> Repeatable.Repeatable PatternChar deconstructRepeatablePatternChar (MkRepeatablePatternChar repeatable)	= repeatable -instance SelfValidate.SelfValidator RepeatablePatternChar	where-	isValid	= SelfValidate.isValid . deconstructRepeatablePatternChar+instance ToolShed.SelfValidate.SelfValidator RepeatablePatternChar	where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstructRepeatablePatternChar  instance Consumer.Consumer RepeatablePatternChar	where 	consumptionProfile	= Consumer.consumptionProfile . deconstructRepeatablePatternChar@@ -181,7 +181,7 @@  		prop_io r		= Test.QuickCheck.label "prop_io" $ read (show r) == r 		prop_io' r		= Test.QuickCheck.label "prop_io'" $ read (show r') == r'	where r' = ExtendedRegExChar.extendedRegEx r	--Check "RegEx.ExtendedRegEx Char" too.-		prop_isValid r		= Test.QuickCheck.label "prop_isValid" $ SelfValidate.isValid r+		prop_isValid r		= Test.QuickCheck.label "prop_isValid" $ ToolShed.SelfValidate.isValid r 		prop_starHeight r	= Test.QuickCheck.label "prop_starHeight" $ (Consumer.starHeight r == 0) == ConsumptionBounds.isPrecise (Consumer.getConsumptionBounds r)  	quickChecks2	= Test.QuickCheck.quickCheck {-'checker' is technically the wrong type-} `mapM_` [prop_double]	where
src/Grecce/Test/QC/RepeatableMetaChar.hs view
@@ -32,6 +32,7 @@ 	quickChecks ) where +import qualified	Data.Maybe import			Control.Applicative((<$>)) import			Grecce.Test.QC.MetaChar() import qualified	RegExChar.MetaChar		as MetaChar@@ -40,7 +41,7 @@ import qualified	RegExDot.ConsumptionProfile	as ConsumptionProfile import qualified	RegExDot.Repeatable		as Repeatable import qualified	Test.QuickCheck-import qualified	ToolShed.SelfValidate		as SelfValidate+import qualified	ToolShed.SelfValidate  -- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'. newtype RepeatableMetaChar	= MkRepeatableMetaChar (Repeatable.Repeatable MetaChar.MetaChar)	deriving (Eq, Read, Show)@@ -49,8 +50,8 @@ deconstruct :: RepeatableMetaChar -> Repeatable.Repeatable MetaChar.MetaChar deconstruct (MkRepeatableMetaChar repeatableMetaChar)	= repeatableMetaChar -instance SelfValidate.SelfValidator RepeatableMetaChar	where-	isValid	= SelfValidate.isValid . deconstruct+instance ToolShed.SelfValidate.SelfValidator RepeatableMetaChar	where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstruct  instance Consumer.Consumer RepeatableMetaChar	where 	consumptionProfile	= Consumer.consumptionProfile . deconstruct@@ -82,17 +83,14 @@ quickChecks :: (Testable -> IO ()) -> IO () quickChecks checker	= checker `mapM_` [prop_consumptionProfile, prop_io, prop_isValid, prop_starHeight]	where 	prop_consumptionProfile, prop_io, prop_isValid, prop_starHeight :: Testable-	prop_consumptionProfile r	= Test.QuickCheck.label "prop_consumptionProfile" $ (-		case maybeMaxData of-			Nothing	-> True-			Just m	-> m >= minData-	 ) && (-		b == Consumer.getHasSpecificRequirement (Repeatable.base $ deconstruct r)-	 ) where ConsumptionProfile.MkConsumptionProfile {+	prop_consumptionProfile r	= Test.QuickCheck.label "prop_consumptionProfile" $ Data.Maybe.maybe True (>= minData) maybeMaxData && b == Consumer.getHasSpecificRequirement (Repeatable.base $ deconstruct r)	where ConsumptionProfile.MkConsumptionProfile { 		ConsumptionProfile.consumptionBounds		= (minData, maybeMaxData), 		ConsumptionProfile.hasSpecificRequirement	= b-	 } = Consumer.consumptionProfile r+	} = Consumer.consumptionProfile r+ 	prop_io (MkRepeatableMetaChar r)		= Test.QuickCheck.label "prop_io" $ read (show r) == r-	prop_isValid r					= Test.QuickCheck.label "prop_isValid" $ SelfValidate.isValid r++	prop_isValid r					= Test.QuickCheck.label "prop_isValid" $ ToolShed.SelfValidate.isValid r+ 	prop_starHeight (MkRepeatableMetaChar r)	= Test.QuickCheck.label "prop_starHeight" $ Consumer.starHeight r == if ConsumptionBounds.isPrecise (Consumer.getConsumptionBounds r) then 0 else 1 
src/Main.hs view
@@ -29,15 +29,16 @@ -}  module Main(--- * Type-classes+-- * Types+-- ** Type-synonyms --	CommandLineAction, -- * Functions--- $main 	main	--Added for Haskell style scanner, 'scan-0.1.0.5'. ) where  import			Control.Applicative((<$>)) import qualified	Data.List+import qualified	Data.Version import qualified	Distribution.Package import qualified	Distribution.Text import qualified	Distribution.Version@@ -48,13 +49,15 @@ import qualified	Grecce.Test.Performance.ExtendedRegExTestsNegative	as Test.Performance.ExtendedRegExTestsNegative import qualified	Grecce.Test.Performance.ExtendedRegExTestsPositive	as Test.Performance.ExtendedRegExTestsPositive import qualified	Grecce.Test.QC.QuickChecks				as Test.QC.QuickChecks+import qualified	Paths_regexchar						as Paths	--Either local stub, or package-instance autogenerated by 'Setup.hs build'. import qualified	RegExDot.CompilationOptions				as CompilationOptions import qualified	RegExDot.ExecutionOptions				as ExecutionOptions-import qualified	System import qualified	System.Console.GetOpt					as G+import qualified	System.Environment+import qualified	System.Exit import qualified	System.IO import qualified	System.IO.Error-import qualified	ToolShed.Defaultable					as Defaultable+import qualified	ToolShed.Defaultable  -- | Used to thread user-defined command-line options, though the list of functions which implement them. type CommandLineAction	= CommandOptions.CommandOptions -> IO CommandOptions.CommandOptions	--Supplied as the type-argument to 'G.OptDescr'.@@ -66,8 +69,8 @@ -} main :: IO () main	= do-	progName	<- System.getProgName-	args		<- System.getArgs+	progName	<- System.Environment.getProgName+	args		<- System.Environment.getArgs  	let 		usage :: String@@ -77,17 +80,17 @@ 		optDescrList :: [G.OptDescr CommandLineAction] 		optDescrList	= [ --				 String	[String]					(G.ArgDescr CommandLineAction)							String-			G.Option "e"	["regex"]					(setExtendedRegExChar `G.ReqArg` "<regex>")					"Input:\tdefine the regex.",-			G.Option "f"	["file"]					(readExtendedRegExCharFromFile `G.ReqArg` "<file-name>")			"Input:\tread the regex from file.",-			G.Option "c"	["count"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setCountMatches)		("Output:\tprint only a count of matching lines per file; default '" ++ show (CommandOptions.countMatches Defaultable.defaultValue) ++ "'."),-			G.Option "l"	["files-with-matches"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setListFilesWithMatches)	("Output:\tlist names of files containing at least one match; default '" ++ show (CommandOptions.listFilesWithMatches Defaultable.defaultValue) ++ "'."),-			G.Option "L"	["files-without-match"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setListFilesWithoutMatch)	("Output:\tlist names of files not containing any matches; default '" ++ show (CommandOptions.listFilesWithoutMatch Defaultable.defaultValue) ++ "'."),-			G.Option "n"	["number"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setPrependLineNumbers)	("Output:\tprepend the line-number of the input, to the output; default '" ++ show (CommandOptions.prependLineNumbers Defaultable.defaultValue) ++ "'."),-			G.Option "v"	["invert-match"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setInvertMatch)		("Output:\tselect non-matching lines; default '" ++ show (CommandOptions.invertMatch Defaultable.defaultValue) ++ "'."),-			G.Option ""	["version"]					(G.NoArg $ const printVersion)							"Output:\tprint version-information & then exit.", 			G.Option "?"	["help"]					(G.NoArg $ const printUsage)							"Output:\tdisplay this help-text & then exit.",+			G.Option ""	["verbose"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setVerbose)			("Output:\tsee how the input data was captured by the RegEx; default '" ++ show (CommandOptions.verbose ToolShed.Defaultable.defaultValue) ++ "'. CAVEAT: to be effective, it should precede other options."),+			G.Option ""	["version"]					(G.NoArg $ const printVersion)							"Output:\tprint version-information & then exit.",+			G.Option "c"	["count"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setCountMatches)		("Output:\tprint only a count of matching lines per file; default '" ++ show (CommandOptions.countMatches ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option "l"	["files-with-matches"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setListFilesWithMatches)	("Output:\tlist names of files containing at least one match; default '" ++ show (CommandOptions.listFilesWithMatches ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option "L"	["files-without-match"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setListFilesWithoutMatch)	("Output:\tlist names of files not containing any matches; default '" ++ show (CommandOptions.listFilesWithoutMatch ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option "n"	["number"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setPrependLineNumbers)	("Output:\tprepend the line-number of the input, to the output; default '" ++ show (CommandOptions.prependLineNumbers ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option "v"	["invert-match"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setInvertMatch)		("Output:\tselect non-matching lines; default '" ++ show (CommandOptions.invertMatch ToolShed.Defaultable.defaultValue) ++ "'."), 			G.Option ""	["printCurrentSettings"]			(G.NoArg printCurrentSettings)							"Output:\tdisplay the currently defined options & then exit.",-			G.Option ""	["verbose"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setVerbose)			("Output:\tsee how the input data was captured by the RegEx; default '" ++ show (CommandOptions.verbose Defaultable.defaultValue) ++ "'."),+			G.Option "e"	["regex"]					(setExtendedRegExChar `G.ReqArg` "<regex>")					"Input:\tdefine the regex.",+			G.Option "f"	["file"]					(readExtendedRegExCharFromFile `G.ReqArg` "<file-name>")			"Input:\tread the regex from file.", 			G.Option ""	["performance"]					( 				extendedRegExCharPerformance `G.ReqArg` "(Int,Either [TestName])" 			) (@@ -100,41 +103,41 @@ 			G.Option ""	["runQuickChecks"]				(G.NoArg runQuickChecks)							"Test:\trun Quick-checks using arbitrary data & then exit. Specify 'verbose' before this option, for detailed output.", 			G.Option ""	["assert"]					(assertFromFile `G.ReqArg` "<file-name>")					"Test:\trun the assertions, defined in the specified file, & then exit. NB: specify this option last.", 			G.Option ""	["assertPosix"]					(assertPosixFromFile `G.ReqArg` "<file-name>")					"Test:\trun the assertions, defined in the specified file, against Text.Regex.Posix, & then exit. NB: specify this option last.",-			G.Option ""	["abortTrialRepetitionsOnInherentFailure"]	(setExecutionOption abortTrialRepetitionsOnInherentFailure `G.ReqArg` "Bool")	("Performance:\tif an alternative can't match, irrespective of the subsequent concatenation, then terminate futile trial repetitions; default '" ++ show (ExecutionOptions.abortTrialRepetitionsOnInherentFailure Defaultable.defaultValue) ++ "'."),---			G.Option ""	["abortTrialRepetitionsOnZeroConsumption"]	(setExecutionOption abortTrialRepetitionsOnZeroConsumption `G.ReqArg` "Bool")	("Performance:\tcheck for zero data-consumption by the n-th repetition of an alternative, before considering (n + 1); default '" ++ show (ExecutionOptions.abortTrialRepetitionsOnZeroConsumption Defaultable.defaultValue) ++ "'."),---			G.Option ""	["bypassInputDataForLiberalConsumer"]		(setExecutionOption bypassInputDataForLiberalConsumer `G.ReqArg` "Bool")	("Performance:\tbypass reading of the unconsumed input data, if the remaining RegEx can consume a sufficient quantity of anything; default '" ++ show (ExecutionOptions.bypassInputDataForLiberalConsumer Defaultable.defaultValue) ++ "'."),-			G.Option ""	["catchIncompatibleAnchors"]			(setExecutionOption catchIncompatibleAnchors `G.ReqArg` "Bool")			("Performance:\tavoid futile trial solutions, involving repetitions of anchored alternatives, which must consume data; default '" ++ show (ExecutionOptions.catchIncompatibleAnchors Defaultable.defaultValue) ++ "'."),-			G.Option ""	["checkExistenceOfInelasticTail"]		(setExecutionOption checkExistenceOfInelasticTail `G.ReqArg` "Bool")		("Performance:\tif the regex ends in one or more Meta-data, whose repetition-range is precisely defined, check that this sequence exists at the end of the input data; default '" ++ show (ExecutionOptions.checkExistenceOfInelasticTail Defaultable.defaultValue) ++ "'."),-			G.Option ""	["checkForUnconsumableData"]			(setExecutionOption checkForUnconsumableData `G.ReqArg` "Bool")			("Performance:\tcheck whether there's no possibility of consuming some of the input data; default '" ++ show (ExecutionOptions.checkForUnconsumableData Defaultable.defaultValue) ++ "'."),-			G.Option ""	["complyStrictlyWithPosix"]			(setCompilationOption complyStrictlyWithPosix `G.ReqArg` "Bool")		("Output:\tdefine the offset of captured data, corresponding to a sub-expression which matched zero times, as the artificial value -1 specified by Posix; currently only affects results of 'assert'; default '" ++ show (CompilationOptions.complyStrictlyWithPosix Defaultable.defaultValue) ++ "'."),-			G.Option ""	["moderateGreed"]				(setExecutionOption moderateGreed `G.ReqArg` "Bool")				("Performance:\tgreedily consume data, only up to the limit beyond which, future requirements would be compromised; default '" ++ show (ExecutionOptions.moderateGreed Defaultable.defaultValue) ++ "'."),-			G.Option ""	["permitReorderingOfAlternatives"]		(setExecutionOption permitReorderingOfAlternatives `G.ReqArg` "Bool")		("Performance:\tpermit alternatives to be re-ordered, in an attempt to process the cheapest first; default '" ++ show (ExecutionOptions.permitReorderingOfAlternatives Defaultable.defaultValue) ++ "'."),-			G.Option ""	["preferAlternativesWhichFeedTheGreedy"]	(setExecutionOption preferAlternativesWhichFeedTheGreedy `G.ReqArg` "Bool")	("Preference:\tprefer solutions in which the choice of alternatives directs data from non-greedy to greedy consumers; default '" ++ show (ExecutionOptions.preferAlternativesWhichFeedTheGreedy Defaultable.defaultValue) ++ "'."),-			G.Option ""	["preferAlternativesWhichMimickUnrolling"]	(setExecutionOption preferAlternativesWhichMimickUnrolling `G.ReqArg` "Bool")	("Preference:\tprefer solutions in which the choice of alternatives consumes data like the unrolled repeatable group; default '" ++ show (ExecutionOptions.preferAlternativesWhichMimickUnrolling Defaultable.defaultValue) ++ "'."),-			G.Option ""	["preferFewerRepeatedAlternatives"]		(setExecutionOption preferFewerRepeatedAlternatives `G.ReqArg` "Bool")		("Preference:\tprefer solutions employing fewer repetitions of alternatives, to discourage the capture of null lists; default '" ++ show (ExecutionOptions.preferFewerRepeatedAlternatives Defaultable.defaultValue) ++ "'."),-			G.Option ""	["unrollRepeatedSingletonAlternative"]		(setExecutionOption unrollRepeatedSingletonAlternative `G.ReqArg` "Bool")	("Performance:\tunroll repetitions of singleton alternatives; this doesn't affect the result; default '" ++ show (ExecutionOptions.unrollRepeatedSingletonAlternative Defaultable.defaultValue) ++ "'."),-			G.Option ""	["useFirstMatchAmongAlternatives"]		(setExecutionOption useFirstMatchAmongAlternatives `G.ReqArg` "Bool")		("Performance:\trather than performing an exhaustive search for the optimal choice amongst alternatives, merely select the first that matches; conform to Perl rather than Posix; default '" ++ show (ExecutionOptions.useFirstMatchAmongAlternatives Defaultable.defaultValue) ++ "'."),-			G.Option ""	["validateMinConsumptionOfAlternatives"]	(setExecutionOption validateMinConsumptionOfAlternatives `G.ReqArg` "Bool")	("Performance:\twhen the number of repetitions of a group of alternatives is precisely specified, check the availability of the resulting minimum data-requirement; default '" ++ show (ExecutionOptions.validateMinConsumptionOfAlternatives Defaultable.defaultValue) ++ "'.")+			G.Option ""	["abortTrialRepetitionsOnInherentFailure"]	(setExecutionOption abortTrialRepetitionsOnInherentFailure `G.ReqArg` "Bool")	("Performance:\tif an alternative can't match, irrespective of the subsequent concatenation, then terminate futile trial repetitions; default '" ++ show (ExecutionOptions.abortTrialRepetitionsOnInherentFailure ToolShed.Defaultable.defaultValue) ++ "'."),+--			G.Option ""	["abortTrialRepetitionsOnZeroConsumption"]	(setExecutionOption abortTrialRepetitionsOnZeroConsumption `G.ReqArg` "Bool")	("Performance:\tcheck for zero data-consumption by the n-th repetition of an alternative, before considering (n + 1); default '" ++ show (ExecutionOptions.abortTrialRepetitionsOnZeroConsumption ToolShed.Defaultable.defaultValue) ++ "'."),+--			G.Option ""	["bypassInputDataForLiberalConsumer"]		(setExecutionOption bypassInputDataForLiberalConsumer `G.ReqArg` "Bool")	("Performance:\tbypass reading of the unconsumed input data, if the remaining RegEx can consume a sufficient quantity of anything; default '" ++ show (ExecutionOptions.bypassInputDataForLiberalConsumer ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["catchIncompatibleAnchors"]			(setExecutionOption catchIncompatibleAnchors `G.ReqArg` "Bool")			("Performance:\tavoid futile trial solutions, involving repetitions of anchored alternatives, which must consume data; default '" ++ show (ExecutionOptions.catchIncompatibleAnchors ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["checkExistenceOfInelasticTail"]		(setExecutionOption checkExistenceOfInelasticTail `G.ReqArg` "Bool")		("Performance:\tif the regex ends in one or more Meta-data, whose repetition-range is precisely defined, check that this sequence exists at the end of the input data; default '" ++ show (ExecutionOptions.checkExistenceOfInelasticTail ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["checkForUnconsumableData"]			(setExecutionOption checkForUnconsumableData `G.ReqArg` "Bool")			("Performance:\tcheck whether there's no possibility of consuming some of the input data; default '" ++ show (ExecutionOptions.checkForUnconsumableData ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["moderateGreed"]				(setExecutionOption moderateGreed `G.ReqArg` "Bool")				("Performance:\tgreedily consume data, only up to the limit beyond which, future requirements would be compromised; default '" ++ show (ExecutionOptions.moderateGreed ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["permitReorderingOfAlternatives"]		(setExecutionOption permitReorderingOfAlternatives `G.ReqArg` "Bool")		("Performance:\tpermit alternatives to be re-ordered, in an attempt to process the cheapest first; default '" ++ show (ExecutionOptions.permitReorderingOfAlternatives ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["preferAlternativesWhichFeedTheGreedy"]	(setExecutionOption preferAlternativesWhichFeedTheGreedy `G.ReqArg` "Bool")	("Preference:\tprefer solutions in which the choice of alternatives directs data from non-greedy to greedy consumers; default '" ++ show (ExecutionOptions.preferAlternativesWhichFeedTheGreedy ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["preferAlternativesWhichMimickUnrolling"]	(setExecutionOption preferAlternativesWhichMimickUnrolling `G.ReqArg` "Bool")	("Preference:\tprefer solutions in which the choice of alternatives consumes data like the unrolled repeatable group; default '" ++ show (ExecutionOptions.preferAlternativesWhichMimickUnrolling ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["preferFewerRepeatedAlternatives"]		(setExecutionOption preferFewerRepeatedAlternatives `G.ReqArg` "Bool")		("Preference:\tprefer solutions employing fewer repetitions of alternatives, to discourage the capture of null lists; default '" ++ show (ExecutionOptions.preferFewerRepeatedAlternatives ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["unrollRepeatedSingletonAlternative"]		(setExecutionOption unrollRepeatedSingletonAlternative `G.ReqArg` "Bool")	("Performance:\tunroll repetitions of singleton alternatives; this doesn't affect the result; default '" ++ show (ExecutionOptions.unrollRepeatedSingletonAlternative ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["useFirstMatchAmongAlternatives"]		(setExecutionOption useFirstMatchAmongAlternatives `G.ReqArg` "Bool")		("Performance:\trather than performing an exhaustive search for the optimal choice amongst alternatives, merely select the first that matches; conform to Perl rather than Posix; default '" ++ show (ExecutionOptions.useFirstMatchAmongAlternatives ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["validateMinConsumptionOfAlternatives"]	(setExecutionOption validateMinConsumptionOfAlternatives `G.ReqArg` "Bool")	("Performance:\twhen the number of repetitions of a group of alternatives is precisely specified, check the availability of the resulting minimum data-requirement; default '" ++ show (ExecutionOptions.validateMinConsumptionOfAlternatives ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option ""	["complyStrictlyWithPosix"]			(setCompilationOption complyStrictlyWithPosix `G.ReqArg` "Bool")		("Output:\tdefine the offset of captured data, corresponding to a sub-expression which matched zero times, as the artificial value -1 specified by Posix; currently only affects results of 'assert'; default '" ++ show (CompilationOptions.complyStrictlyWithPosix ToolShed.Defaultable.defaultValue) ++ "'.") 		 ] where 			printVersion, printUsage :: IO CommandOptions.CommandOptions -			printVersion	= System.IO.hPutStrLn System.IO.stderr (Distribution.Text.display packageIdentifier ++ "\n\nCopyright (C) 2010 Dr. Alistair Ward.\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions.\n\nWritten by Dr. Alistair Ward.")	>> System.exitWith System.ExitSuccess	where+			printVersion	= System.IO.hPutStrLn System.IO.stderr (Distribution.Text.display packageIdentifier ++ "\n\nCopyright (C) 2010 Dr. Alistair Ward.\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions.\n\nWritten by Dr. Alistair Ward.")	>> System.Exit.exitWith System.Exit.ExitSuccess	where 				packageIdentifier :: Distribution.Package.PackageIdentifier 				packageIdentifier	= Distribution.Package.PackageIdentifier { 					Distribution.Package.pkgName	= Distribution.Package.PackageName "grecce",-					Distribution.Package.pkgVersion	= Distribution.Version.Version [0, 9, 0, 8] []+					Distribution.Package.pkgVersion	= Distribution.Version.Version (Data.Version.versionBranch Paths.version) [] 				} -			printUsage	= System.IO.hPutStrLn System.IO.stderr usage	>> System.exitWith System.ExitSuccess+			printUsage	= System.IO.hPutStrLn System.IO.stderr usage	>> System.Exit.exitWith System.Exit.ExitSuccess  			printCurrentSettings, runQuickChecks :: CommandLineAction-			printCurrentSettings commandOptions	= print commandOptions	>> System.exitWith System.ExitSuccess-			runQuickChecks commandOptions		= Test.QC.QuickChecks.run (CommandOptions.verbose commandOptions)	>> System.exitWith System.ExitSuccess+			printCurrentSettings commandOptions	= print commandOptions	>> System.Exit.exitWith System.Exit.ExitSuccess+			runQuickChecks commandOptions		= Test.QC.QuickChecks.run (CommandOptions.verbose commandOptions)	>> System.Exit.exitWith System.Exit.ExitSuccess  			extendedRegExCharPerformance, readExtendedRegExCharFromFile, assertFromFile, assertPosixFromFile, setExtendedRegExChar :: String -> CommandLineAction 			extendedRegExCharPerformance s commandOptions	= ( 				uncurry $ Test.Performance.ExtendedRegEx.run (CommandOptions.executionOptions commandOptions)-			 ) (read s)	>> System.exitWith System.ExitSuccess+			 ) (read s)	>> System.Exit.exitWith System.Exit.ExitSuccess  			readExtendedRegExCharFromFile s commandOptions	= (head . dropWhile null . lines <$> readFile s) >>= (`setExtendedRegExChar` commandOptions) @@ -142,21 +145,21 @@ 				failedTests	<- Test.Assert.RegExOptsChar.findFailures (CommandOptions.compilationOptions commandOptions) (CommandOptions.executionOptions commandOptions) <$> Test.Assert.RegExOptsChar.readTests fileName  				if null failedTests-					then System.exitWith System.ExitSuccess+					then System.Exit.exitWith System.Exit.ExitSuccess 					else do 						mapM_ print failedTests -						System.exitWith $ System.ExitFailure 2+						System.Exit.exitWith $ System.Exit.ExitFailure 2  			assertPosixFromFile fileName _	= do 				failedTests	<- Test.Assert.RegExOptsChar.findFailuresPosix <$> Test.Assert.RegExOptsChar.readTests fileName  				if null failedTests-					then System.exitWith System.ExitSuccess+					then System.Exit.exitWith System.Exit.ExitSuccess 					else do 						mapM_ print failedTests -						System.exitWith $ System.ExitFailure 2+						System.Exit.exitWith $ System.Exit.ExitFailure 2  			setExtendedRegExChar s commandOptions	= case CommandOptions.extendedRegExChar commandOptions of 				Just e	-> error $ "'" ++ show e ++ "' has already been defined"@@ -190,7 +193,7 @@ --	G.getOpt :: G.ArgOrder CommandLineAction -> [G.OptDescr Action] -> [String] -> ([Action], [String], [String]) 	case G.getOpt G.RequireOrder optDescrList args of 		(commandLineActions, nonOptions, [])	-> do-			commandOptions	<- Data.List.foldl' (>>=) (return {-to IO-monad-} Defaultable.defaultValue) commandLineActions	--Sequentially transform the 'CommandOptions', using 'CommandLineAction's corresponding to the specified command-line flags.+			commandOptions	<- Data.List.foldl' (>>=) (return {-to IO-monad-} ToolShed.Defaultable.defaultValue) commandLineActions	--Sequentially transform the 'CommandOptions', using 'CommandLineAction's corresponding to the specified command-line flags.  			Grep.grep commandOptions nonOptions	--Perform the requested match, against the list of input-data files. 		(_, _, errors)	-> System.IO.Error.ioError . System.IO.Error.userError $ concat errors ++ usage	--Throw.
src/RegExChar/ExtendedRegExChar.hs view
@@ -33,20 +33,19 @@ 	(/~) ) where -import			Control.Applicative((<$>))-import			RegExDot.DSL((<~>), (-:))-import			Text.ParserCombinators.Parsec((<?>), (<|>))-import qualified	Control.Monad+import			Control.Applicative((<$>), (<*>)) import qualified	Data.List import qualified	RegExChar.MetaChar		as MetaChar import qualified	RegExDot.Anchor			as Anchor import qualified	RegExDot.Consumer		as Consumer+import			RegExDot.DSL((<~>), (-:)) import qualified	RegExDot.RegEx			as RegEx import qualified	RegExDot.RegExOpts		as RegExOpts import qualified	RegExDot.Repeatable		as Repeatable import qualified	Text.ParserCombinators.Parsec	as Parsec-import qualified	ToolShed.Pair			as Pair-import qualified	ToolShed.SelfValidate		as SelfValidate+import			Text.ParserCombinators.Parsec((<?>), (<|>))+import qualified	ToolShed.Data.Pair+import qualified	ToolShed.SelfValidate  infix 4 +~, =~, /~	--Same as (==) & (/=). @@ -59,11 +58,15 @@ -- | Abbreviation. type InputData	= RegEx.InputData Char -instance SelfValidate.SelfValidator ExtendedRegExChar	where-	isValid MkExtendedRegExChar {+instance ToolShed.SelfValidate.SelfValidator ExtendedRegExChar	where+	getErrors MkExtendedRegExChar { 		hasNonCapturingTopLevelAlternatives	= hasNonCapturingTopLevelAlternatives', 		extendedRegEx				= extendedRegEx'-	} = (not hasNonCapturingTopLevelAlternatives' || all (RegEx.isCaptureGroup . Repeatable.base) (RegEx.concatenation extendedRegEx')) && SelfValidate.isValid extendedRegEx'+	}+		| not $ ToolShed.SelfValidate.isValid extendedRegEx'	= ToolShed.SelfValidate.getErrors extendedRegEx'+		| otherwise						= ToolShed.SelfValidate.extractErrors [+			(hasNonCapturingTopLevelAlternatives' && any (not . RegEx.isCaptureGroup . Repeatable.base) (RegEx.concatenation extendedRegEx'), "Invalid NonCapturingTopLevelAlternatives.")+		]  instance Consumer.Consumer ExtendedRegExChar	where 	consumptionProfile	= Consumer.consumptionProfile . extendedRegEx@@ -101,7 +104,7 @@ 						( 							do 								repeatableCaptureGroup	<- Repeatable.repeatableParser . RegEx.CaptureGroup =<< uncurry Parsec.between (-									Pair.mirror Parsec.char RegEx.captureGroupDelimiters+									ToolShed.Data.Pair.mirror Parsec.char RegEx.captureGroupDelimiters 								 ) alternativesParser {-recurse-} <?> "RegEx.captureGroupDelimiters " ++ show RegEx.captureGroupDelimiters  								extendedRegEx'	<- extendedRegExParser	--Recurse.@@ -129,14 +132,20 @@ 										Parsec.oneOf [RegEx.alternativeExtendedRegExSeparatorToken, snd RegEx.captureGroupDelimiters] >> return {-to GenParser-monad-} [] 									) 								),-								Control.Monad.liftM2 (:) (-									 MetaChar.metaCharParser >>= Repeatable.repeatableParser . RegEx.Require . MetaChar.deconstruct-								) repeatableRequirementListParser, {-recurse-}+								(:) <$> (+									MetaChar.metaCharParser >>= Repeatable.repeatableParser . RegEx.Require . MetaChar.deconstruct+								) <*> repeatableRequirementListParser, {-recurse-} 								return {-to GenParser-monad-} [] 							 ] -		in (error . ("readsPrec RegExChar.ExtendedRegExChar:\tparse-error; " ++) . show) `either` (filter (SelfValidate.isValid . fst) . return) $ Parsec.parse (-			Control.Monad.liftM2 (,) extendedRegExCharParser Parsec.getInput+		in (+			error . ("readsPrec RegExChar.ExtendedRegExChar:\tparse-error; " ++) . show	--Failure to parse.+		) `either` (+			\pair@(extendedRegExChar, _)	-> if ToolShed.SelfValidate.isValid extendedRegExChar+				then [pair]+				else error $ ToolShed.SelfValidate.getFirstError extendedRegExChar	--Parsed OK, but invalid.+		) $ Parsec.parse (+			(,) <$> extendedRegExCharParser <*> Parsec.getInput 		) "ExtendedRegExChar" s  instance Show ExtendedRegExChar	where@@ -175,22 +184,22 @@ 	 ) . RegEx.showsMaybeAnchor maybeSternAnchor  -- | A veneer over the underlying polymorphic operator, 'RegEx.+~'.-(+~) ::-	InputData					-- ^ The input-data string.+(+~)+	:: InputData					-- ^ The input-data string. 	-> RegExOpts.RegExOpts ExtendedRegExChar	-- ^ The match-options, parameterised by the regex-specification. 	-> RegEx.Result Char inputData +~ regExOpts	= inputData RegEx.+~ fmap extendedRegEx regExOpts	--CAVEAT: <http://hackage.haskell.org/trac/haskell-prime/wiki/QualifiedOperators>.  -- | A veneer over the underlying polymorphic operator, 'RegEx.=~'.-(=~) ::-	InputData					-- ^ The input-data string.+(=~)+	:: InputData					-- ^ The input-data string. 	-> RegExOpts.RegExOpts ExtendedRegExChar	-- ^ The match-options, parameterised by the regex-specification. 	-> Bool inputData =~ regExOpts	= inputData RegEx.=~ fmap extendedRegEx regExOpts	--CAVEAT: <http://hackage.haskell.org/trac/haskell-prime/wiki/QualifiedOperators>.  -- | Pattern-mismatch operator.-(/~) ::-	InputData					-- ^ The input-data string.+(/~)+	:: InputData					-- ^ The input-data string. 	-> RegExOpts.RegExOpts ExtendedRegExChar	-- ^ The match-options, parameterised by the regex-specification. 	-> Bool (/~) inputData	= not . (inputData =~)
src/RegExChar/MetaChar.hs view
@@ -60,10 +60,8 @@ 	deconstruct ) where -import			Control.Applicative((<$>))+import			Control.Applicative((<$>), (<*>)) import			Control.Arrow((***))-import			Text.ParserCombinators.Parsec((<?>))-import qualified	Control.Monad import qualified	Data.Char import qualified	Data.Map import qualified	RegExDot.BracketExpression		as BracketExpression@@ -74,8 +72,9 @@ import qualified	RegExDot.Repeatable			as Repeatable import qualified	RegExDot.ShowablePredicate		as ShowablePredicate import qualified	Text.ParserCombinators.Parsec		as Parsec-import qualified	ToolShed.Pair				as Pair-import qualified	ToolShed.SelfValidate			as SelfValidate+import			Text.ParserCombinators.Parsec((<?>))+import qualified	ToolShed.Data.Pair+import qualified	ToolShed.SelfValidate  -- | Holds a mapping from an escape-sequence & the predicate via which it is implemented. type AssociationList key	= [(key, ShowablePredicate.Predicate Char)]@@ -109,8 +108,8 @@ deconstruct :: MetaChar -> Meta.Meta Char deconstruct (MkMetaChar metaChar)	= metaChar -instance SelfValidate.SelfValidator MetaChar	where-	isValid	= SelfValidate.isValid . deconstruct+instance ToolShed.SelfValidate.SelfValidator MetaChar	where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstruct  instance Consumer.Consumer MetaChar	where 	consumptionProfile	= Consumer.consumptionProfile . deconstruct@@ -121,7 +120,7 @@ metaCharParser	= MkMetaChar <$> Parsec.choice [ 	(Parsec.char Meta.anyToken <?> "Meta.anyToken " ++ show Meta.anyToken) >> return {-to GenParser-monad-} Meta.Any, 	(Parsec.char Meta.shortcutToken <?> "Meta.shortcutToken " ++ show Meta.shortcutToken) >> Meta.expand <$> Parsec.anyChar,-	uncurry Parsec.between (Pair.mirror Parsec.char BracketExpression.delimiterTokens) (+	uncurry Parsec.between (ToolShed.Data.Pair.mirror Parsec.char BracketExpression.delimiterTokens) ( 		do 			let 				implementPosixCharacterClass :: String -> Maybe (ShowablePredicate.ShowablePredicate Char)@@ -169,7 +168,7 @@ 								_			-> BracketExpressionMember.Literal c	--Escaped literal. 					) <?> "Perl-style shortcut", 					Parsec.try (-						uncurry Parsec.between (Pair.mirror Parsec.string posixCharacterClassDelimiters) (+						uncurry Parsec.between (ToolShed.Data.Pair.mirror Parsec.string posixCharacterClassDelimiters) ( 							do 								identifier	<- Parsec.many1 $ Parsec.noneOf [head $ snd posixCharacterClassDelimiters] @@ -203,7 +202,7 @@ 	readsPrec _	= ( 		(error . ("readsPrec RegExChar.MetaChar:\tparse-error; " ++) . show) `either` return 	 ) . Parsec.parse (-		Control.Monad.liftM2 (,) metaCharParser Parsec.getInput+		(,) <$> metaCharParser <*> Parsec.getInput 	 ) "MetaChar"  -- | The token used to signify an ordered range of members in a /Bracket-expression/.
src/RegExChar/RegExOptsChar.hs view
@@ -50,8 +50,7 @@ ) where  import			Control.Applicative((<$>))-import			Text.Regex.Base.Context()	--Instance-declarations.-import qualified	Data.Array+import qualified	Data.Array.IArray import qualified	RegExChar.ExtendedRegExChar	as ExtendedRegExChar import qualified	RegExDot.CompilationOptions	as CompilationOptions import qualified	RegExDot.ConsumptionBounds	as ConsumptionBounds@@ -63,9 +62,10 @@ import qualified	RegExDot.Result			as Result import qualified	RegExDot.Tree			as Tree import qualified	Text.Regex.Base.RegexLike	as RegexLike-import qualified	ToolShed.ListPlus		as ListPlus-import qualified	ToolShed.Defaultable		as Defaultable-import qualified	ToolShed.Options		as Options+import			Text.Regex.Base.Context()	--Instance-declarations.+import qualified	ToolShed.Data.List+import qualified	ToolShed.Defaultable+import qualified	ToolShed.Options  infix 4 =~	--Same as (==). @@ -81,10 +81,10 @@ complyStrictlyWithPosix	= CompilationOptions.complyStrictlyWithPosix . RegExOpts.compilationOptions  instance RegexLike.RegexOptions RegExOptsChar CompilationOptions.CompilationOptions ExecutionOptions.ExecutionOptions	where-	blankCompOpt	= Options.blankValue-	blankExecOpt	= Options.blankValue-	defaultCompOpt	= Defaultable.defaultValue-	defaultExecOpt	= Defaultable.defaultValue+	blankCompOpt	= ToolShed.Options.blankValue+	blankExecOpt	= ToolShed.Options.blankValue+	defaultCompOpt	= ToolShed.Defaultable.defaultValue+	defaultExecOpt	= ToolShed.Defaultable.defaultValue 	setExecOpts e r	= r { RegExOpts.executionOptions = e } 	getExecOpts	= RegExOpts.executionOptions @@ -113,8 +113,8 @@  	* CAVEAT: @DataSpanTree.extractCaptureGroups True@ may return some 'DataSpan.DataSpan's containing the artificial offset @-1@ specified by Posix => don't use this as the basis for any arithmetic. -}-toMatchDataSpanList ::-	Bool+toMatchDataSpanList+	:: Bool 	-> ConsumptionBounds.DataLength	-- ^ The offset to use for zero-length match. 	-> RegEx.MatchList Char		-- ^ The list of matches. 	-> [MatchDataSpan]@@ -124,20 +124,20 @@ -- | Optionally remove the 2nd element from the list, where it represents the data captured by a groups of top-level 'Alternatives', which weren't explicitly delimited & therefore are non-capturing. exciseNonCapturingTopLevelAlternatives :: RegExOptsChar -> [MatchDataSpan] -> [MatchDataSpan] exciseNonCapturingTopLevelAlternatives regExOptsChar-	| hasNonCapturingTopLevelAlternatives regExOptsChar	= ListPlus.excise 1	--The zeroeth represents the whole regex, the 1st represents the top-level non-capturing group of Alternatives, & the remainder represent explicitly delimited groups.+	| hasNonCapturingTopLevelAlternatives regExOptsChar	= ToolShed.Data.List.excise 1	--The zeroeth represents the whole regex, the 1st represents the top-level non-capturing group of Alternatives, & the remainder represent explicitly delimited groups. 	| otherwise						= id  -- | Convert the specified list, into a zero-indexed array.-toZeroIndexedArray :: [e] -> Data.Array.Array Int e-toZeroIndexedArray l	= Data.Array.listArray (0, length l - 1) l+toZeroIndexedArray :: [e] -> Data.Array.IArray.Array Int e+toZeroIndexedArray l	= Data.Array.IArray.listArray (0, pred $ length l) l  {- | 	* Repeatedly apply the 'RegExOptsChar' to the 'ExtendedRegExChar.InputData', forwarding unmatched input data to the next match-attempt, until it's all been consumed.  	* The offsets, from the start of the input data, of all matches after the first, are shifted to account for input data already consumed by previous matches. -}-matchUntilFailure ::-	RegExOptsChar			-- ^ The match-criteria.+matchUntilFailure+	:: RegExOptsChar		-- ^ The match-criteria. 	-> ExtendedRegExChar.InputData	-- ^ The input-data, to be consumed by repeated matching. 	-> [RegEx.MatchList Char] matchUntilFailure regExOptsChar inputData	= shiftOffsets 0 $ matchUntilFailure' inputData	where