Hsed 0.2 → 0.2.1
raw patch · 7 files changed
+23/−21 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Hsed.Ast: Address :: (Maybe Addr) -> (Maybe Addr) -> Invert -> Address
+ Hsed.Ast: Append :: Text -> SedFun
+ Hsed.Ast: AppendHold :: SedFun
+ Hsed.Ast: AppendLinePat :: SedFun
+ Hsed.Ast: AppendPat :: SedFun
+ Hsed.Ast: Branch :: (Maybe Label) -> SedFun
+ Hsed.Ast: Change :: Text -> SedFun
+ Hsed.Ast: Comment :: SedFun
+ Hsed.Ast: DeleteLine :: SedFun
+ Hsed.Ast: DeletePat :: SedFun
+ Hsed.Ast: EmptyCmd :: SedFun
+ Hsed.Ast: Exchange :: SedFun
+ Hsed.Ast: Flags :: (Maybe OccurrencePrint) -> (Maybe FilePath) -> Flags
+ Hsed.Ast: Group :: [SedCmd] -> SedFun
+ Hsed.Ast: Insert :: Text -> SedFun
+ Hsed.Ast: Label :: Label -> SedFun
+ Hsed.Ast: LastLine :: Addr
+ Hsed.Ast: LineNum :: SedFun
+ Hsed.Ast: LineNumber :: Int -> Addr
+ Hsed.Ast: List :: SedFun
+ Hsed.Ast: NextLine :: SedFun
+ Hsed.Ast: OccurrencePrint :: (Maybe Occurrence) -> OutputPat -> OccurrencePrint
+ Hsed.Ast: Pat :: Pattern -> Addr
+ Hsed.Ast: PrintOccurrence :: OutputPat -> (Maybe Occurrence) -> OccurrencePrint
+ Hsed.Ast: PrintPat :: SedFun
+ Hsed.Ast: Quit :: SedFun
+ Hsed.Ast: ReadFile :: FilePath -> SedFun
+ Hsed.Ast: Replace :: Int -> Occurrence
+ Hsed.Ast: ReplaceAll :: Occurrence
+ Hsed.Ast: ReplaceHold :: SedFun
+ Hsed.Ast: ReplacePat :: SedFun
+ Hsed.Ast: SedCmd :: Address -> SedFun -> SedCmd
+ Hsed.Ast: Substitute :: Pattern -> Replacement -> Flags -> SedFun
+ Hsed.Ast: Test :: (Maybe Label) -> SedFun
+ Hsed.Ast: Transform :: Text -> Text -> SedFun
+ Hsed.Ast: WriteFile :: FilePath -> SedFun
+ Hsed.Ast: WriteUpPat :: SedFun
+ Hsed.Ast: data Addr
+ Hsed.Ast: data Address
+ Hsed.Ast: data Flags
+ Hsed.Ast: data Occurrence
+ Hsed.Ast: data OccurrencePrint
+ Hsed.Ast: data SedCmd
+ Hsed.Ast: data SedFun
+ Hsed.Ast: instance Show Addr
+ Hsed.Ast: instance Show Address
+ Hsed.Ast: instance Show Flags
+ Hsed.Ast: instance Show Occurrence
+ Hsed.Ast: instance Show OccurrencePrint
+ Hsed.Ast: instance Show SedCmd
+ Hsed.Ast: instance Show SedFun
+ Hsed.Ast: type Invert = Bool
+ Hsed.Ast: type Label = ByteString
+ Hsed.Ast: type OutputPat = Bool
+ Hsed.Ast: type Replacement = ByteString
+ Hsed.Ast: type Text = ByteString
+ Hsed.Parsec: ParserState :: Pattern -> ParserState
+ Hsed.Parsec: address :: SedParser Address
+ Hsed.Parsec: argFun :: Char -> (ByteString -> SedFun) -> SedParser SedFun
+ Hsed.Parsec: bareFun :: Char -> SedFun -> SedParser SedFun
+ Hsed.Parsec: data ParserState
+ Hsed.Parsec: fileFun :: Char -> (FilePath -> SedFun) -> SedParser SedFun
+ Hsed.Parsec: gotoFun :: Char -> (Maybe Label -> SedFun) -> SedParser SedFun
+ Hsed.Parsec: lastRE :: ParserState -> Pattern
+ Hsed.Parsec: parseRE :: String -> SedParser Pattern
+ Hsed.Parsec: parseSed :: SedParser a -> Stream -> Either ParseError a
+ Hsed.Parsec: sedCmd :: SedParser SedCmd
+ Hsed.Parsec: sedCmds :: SedParser [SedCmd]
+ Hsed.Parsec: sedFun :: SedParser SedFun
+ Hsed.Parsec: textFun :: Char -> (Text -> SedFun) -> SedParser SedFun
+ Hsed.Parsec: type SedParser = GenParser Char ParserState
+ Hsed.Parsec: type Stream = String
+ Hsed.SedRegex: sedSubRegex :: ByteString -> ByteString -> ByteString -> Int -> (ByteString, Bool)
+ Hsed.SedRegex: type Pattern = ByteString
+ Hsed.SedState: Env :: [SedCmd] -> !Bool -> !Int -> !Int -> !Bool -> !ByteString -> !ByteString -> [ByteString] -> !ByteString -> !Bool -> !Bool -> [(FilePath, Handle)] -> !Bool -> (Handle, Bool) -> Env
+ Hsed.SedState: appendSpace :: T Env [ByteString]
+ Hsed.SedState: appendSpace_ :: Env -> [ByteString]
+ Hsed.SedState: ast :: T Env [SedCmd]
+ Hsed.SedState: ast_ :: Env -> [SedCmd]
+ Hsed.SedState: curFile :: T Env (Handle, Bool)
+ Hsed.SedState: curFile_ :: Env -> (Handle, Bool)
+ Hsed.SedState: curLine :: T Env Int
+ Hsed.SedState: curLine_ :: Env -> !Int
+ Hsed.SedState: data Env
+ Hsed.SedState: defOutput :: T Env Bool
+ Hsed.SedState: defOutput_ :: Env -> !Bool
+ Hsed.SedState: exit :: T Env Bool
+ Hsed.SedState: exit_ :: Env -> !Bool
+ Hsed.SedState: fileout :: T Env [(FilePath, Handle)]
+ Hsed.SedState: fileout_ :: Env -> [(FilePath, Handle)]
+ Hsed.SedState: get :: T Env a -> SedState a
+ Hsed.SedState: holdSpace :: T Env ByteString
+ Hsed.SedState: holdSpace_ :: Env -> !ByteString
+ Hsed.SedState: inRange :: T Env Bool
+ Hsed.SedState: inRange_ :: Env -> !Bool
+ Hsed.SedState: initEnv :: Env
+ Hsed.SedState: instance Show Env
+ Hsed.SedState: lastLine :: T Env Int
+ Hsed.SedState: lastLine_ :: Env -> !Int
+ Hsed.SedState: memorySpace :: T Env ByteString
+ Hsed.SedState: memorySpace_ :: Env -> !ByteString
+ Hsed.SedState: modify :: T Env a -> (a -> a) -> SedState ()
+ Hsed.SedState: patternSpace :: T Env ByteString
+ Hsed.SedState: patternSpace_ :: Env -> !ByteString
+ Hsed.SedState: set :: T Env a -> a -> SedState ()
+ Hsed.SedState: subst :: T Env Bool
+ Hsed.SedState: subst_ :: Env -> !Bool
+ Hsed.SedState: type SedState = StateT Env IO
+ Hsed.SedState: useMemSpace :: T Env Bool
+ Hsed.SedState: useMemSpace_ :: Env -> !Bool
+ Hsed.StreamEd: Break :: FlowControl
+ Hsed.StreamEd: Cont :: Status
+ Hsed.StreamEd: Continue :: FlowControl
+ Hsed.StreamEd: EOF :: Status
+ Hsed.StreamEd: Exit :: FlowControl
+ Hsed.StreamEd: Goto :: (Maybe ByteString) -> FlowControl
+ Hsed.StreamEd: Next :: FlowControl
+ Hsed.StreamEd: append :: ByteString -> SedState FlowControl
+ Hsed.StreamEd: appendHold :: SedState FlowControl
+ Hsed.StreamEd: appendLinePat :: SedState FlowControl
+ Hsed.StreamEd: appendPat :: SedState FlowControl
+ Hsed.StreamEd: branch :: Maybe Label -> SedState FlowControl
+ Hsed.StreamEd: change :: ByteString -> SedState FlowControl
+ Hsed.StreamEd: compile :: String -> SedState ()
+ Hsed.StreamEd: data FlowControl
+ Hsed.StreamEd: data Status
+ Hsed.StreamEd: deleteLine :: SedState FlowControl
+ Hsed.StreamEd: deletePat :: SedState FlowControl
+ Hsed.StreamEd: eval :: [SedCmd] -> SedState FlowControl
+ Hsed.StreamEd: exchange :: SedState FlowControl
+ Hsed.StreamEd: execCmd :: SedCmd -> SedState FlowControl
+ Hsed.StreamEd: execCmds :: [SedCmd] -> SedState FlowControl
+ Hsed.StreamEd: execute :: [FilePath] -> SedState ()
+ Hsed.StreamEd: goto :: [SedCmd] -> Maybe Label -> [SedCmd]
+ Hsed.StreamEd: group :: [SedCmd] -> SedState FlowControl
+ Hsed.StreamEd: insert :: ByteString -> SedState FlowControl
+ Hsed.StreamEd: instance Eq FlowControl
+ Hsed.StreamEd: instance Eq Status
+ Hsed.StreamEd: instance Show FlowControl
+ Hsed.StreamEd: instance Show Status
+ Hsed.StreamEd: isLastLine :: SedState Bool
+ Hsed.StreamEd: line :: SedState (Status, ByteString)
+ Hsed.StreamEd: lineNum :: SedState FlowControl
+ Hsed.StreamEd: list :: SedState FlowControl
+ Hsed.StreamEd: loop :: [SedCmd] -> SedState ()
+ Hsed.StreamEd: matchAddress :: Address -> SedState Bool
+ Hsed.StreamEd: next :: SedState FlowControl
+ Hsed.StreamEd: printPat :: SedState FlowControl
+ Hsed.StreamEd: printPatSpace :: SedState ()
+ Hsed.StreamEd: prnChar :: Char -> SedState ()
+ Hsed.StreamEd: prnPrintf :: Char -> SedState ()
+ Hsed.StreamEd: prnStr :: ByteString -> SedState ()
+ Hsed.StreamEd: prnStrLn :: ByteString -> SedState ()
+ Hsed.StreamEd: processFiles :: [FilePath] -> SedState ()
+ Hsed.StreamEd: processStdin :: SedState ()
+ Hsed.StreamEd: quit :: SedState FlowControl
+ Hsed.StreamEd: readF :: FilePath -> SedState FlowControl
+ Hsed.StreamEd: replaceHold :: SedState FlowControl
+ Hsed.StreamEd: replacePat :: SedState FlowControl
+ Hsed.StreamEd: runCmd :: SedFun -> SedState FlowControl
+ Hsed.StreamEd: runSed :: [FilePath] -> String -> Env -> IO Env
+ Hsed.StreamEd: substitute :: ByteString -> ByteString -> Flags -> SedState FlowControl
+ Hsed.StreamEd: test :: Maybe Label -> SedState FlowControl
+ Hsed.StreamEd: transform :: ByteString -> ByteString -> SedState FlowControl
+ Hsed.StreamEd: writeF :: FilePath -> SedState FlowControl
+ Hsed.StreamEd: writeUpPat :: SedState FlowControl
Files
- Hsed.cabal +7/−4
- src/Hsed/Ast.hs +1/−1
- src/Hsed/Parsec.hs +1/−1
- src/Hsed/Sed.hs +8/−7
- src/Hsed/SedRegex.hs +2/−4
- src/Hsed/SedState.hs +1/−1
- src/Hsed/StreamEd.hs +3/−3
Hsed.cabal view
@@ -1,6 +1,10 @@ Name: Hsed-Version: 0.2-Description: Haskell Stream Editor+Version: 0.2.1+Description: A version of sed editor in Haskell based on POSIX "The Open Group Base + Specifications Issue 7" IEEE Std 1003.1-2008.+ .+ For the library usage check Hsed.Sed module and for the program usage + take a look in the attached README file License: BSD3 License-File: LICENSE Author: Vitaliy Rukavishnikov@@ -37,8 +41,7 @@ Library Hs-Source-Dirs: src- Exposed-Modules: Hsed.Sed- Other-modules: Hsed.Ast, Hsed.SedRegex, Hsed.Parsec, Hsed.SedState, Hsed.StreamEd+ Exposed-Modules: Hsed.Sed, Hsed.Ast, Hsed.SedRegex, Hsed.Parsec, Hsed.SedState, Hsed.StreamEd Build-Depends: base >= 3.0.3.2 && < 5, Glob >= 0.5.1, cmdargs >= 0.3,
src/Hsed/Ast.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Ast--- Copyright : (c) Vitaliy Rkavishnikov+-- Copyright : (c) Vitaliy Rukavishnikov -- License : BSD-style (see the file LICENSE) -- -- Maintainer : virukav@gmail.com
src/Hsed/Parsec.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Parsec--- Copyright : (c) Vitaliy Rkavishnikov+-- Copyright : (c) Vitaliy Rukavishnikov -- License : BSD-style (see the file LICENSE) -- -- Maintainer : virukav@gmail.com
src/Hsed/Sed.hs view
@@ -1,14 +1,14 @@ -- | -- Module : Sed--- Copyright : (c) Vitaliy Rkavishnikov+-- Copyright : (c) Vitaliy Rukavishnikov -- License : BSD-style (see the file LICENSE) -- -- Maintainer : virukav@gmail.com -- Stability : experimental -- Portability : non-portable ----- This module provides functions to execute the sed script--- +-- This module provides functions to execute the sed script. +-- See 'execScript' below for an example module Hsed.Sed ( execScript@@ -16,16 +16,17 @@ , SedScript ) where -import Control.Monad (when)-import qualified Control.Monad.State as S-import Data.List (isPrefixOf) import qualified Data.ByteString.Char8 as B import Hsed.StreamEd (runSed) import Hsed.SedState type SedScript = String --- | Execute the sed script and print the output to ByteString+-- | Execute the sed script and print the output to ByteString.+--+-- Example. Suppose the ../tests/Transform.in file contains the line 'Hello world!'.+-- The execScript ["../tests/Transform.in"] "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/"+-- will produce 'HELLO WORLD!' bytestring. execScript :: [FilePath] -> SedScript -> IO B.ByteString execScript files script = do env <- runSed files script (initEnv {useMemSpace_ = True})
src/Hsed/SedRegex.hs view
@@ -3,7 +3,7 @@ -- Maintainer : virukav@gmail.com -- Stability : experimental--- Portability : non-portable-- |+-- Portability : non-portable -- The Sed regular expression implementation based on the regex-posix package. @@ -11,7 +11,6 @@ import Data.Array ((!)) import Text.Regex.Posix---import Text.Regex.TDFA import Text.Regex import qualified Data.ByteString.Char8 as B @@ -24,10 +23,9 @@ -> B.ByteString -- ^ Replacement text -> Int -- ^ Occurrence -> (B.ByteString, Bool) -- ^ (Output string, Replacement occurs)---sedSubRegex _ "" _ _ = ("", True)+-- sedSubRegex _ "" _ _ = ("", True) sedSubRegex pat inp repl n = let regexp = makeRegexOpts compExtended defaultExecOpt pat- --let regexp = mkRegex pat -- for TDFA compile _i str [] = \ _m -> B.append str compile i str ((xstr,(off,len)):rest) = let i' = off+len
src/Hsed/SedState.hs view
@@ -2,7 +2,7 @@ -- | -- Module : SedState--- Copyright : (c) Vitaliy Rkavishnikov+-- Copyright : (c) Vitaliy Rukavishnikov -- License : BSD-style (see the file LICENSE) -- -- Maintainer : virukav@gmail.com
src/Hsed/StreamEd.hs view
@@ -2,15 +2,15 @@ -- | -- Module : StreamEd--- Copyright : (c) Vitaliy Rkavishnikov+-- Copyright : (c) Vitaliy Rukavishnikov -- License : BSD-style (see the file LICENSE) -- -- Maintainer : virukav@gmail.com -- Stability : experimental -- Portability : non-portable ----- The Sed runtime engine. The execution sequence includes the parseArgs (parse the Sed options/args),--- compile (parse) Sed commands, execute Sed commands.+-- The Sed runtime engine. The execution sequence includes the parseArgs +-- compile (parse) and execute Sed commands. module Hsed.StreamEd where