Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | virukav@gmail.com |
The Sed runtime engine
- type SedEngine a = GotoT a (StateT Env IO) a
- data Status
- data FlowControl
- runSed :: [FilePath] -> String -> Env -> IO Env
- compile :: String -> SedState ()
- execute :: [FilePath] -> SedEngine ()
- processFiles :: [FilePath] -> SedEngine ()
- nextLine :: SedEngine ()
- execCmds :: [SedCmd] -> SedEngine ()
- jump :: [SedCmd] -> Maybe Label -> [SedCmd]
- line :: SedState (Status, ByteString)
- execCmd :: SedCmd -> SedState FlowControl
- matchAddress :: Address -> SedState Bool
- runCmd :: SedFun -> SedState FlowControl
- group :: [SedCmd] -> SedState FlowControl
- lineNum :: SedState FlowControl
- append :: ByteString -> SedState FlowControl
- branch :: Maybe Label -> SedState FlowControl
- change :: ByteString -> SedState FlowControl
- deleteLine :: SedState FlowControl
- deletePat :: SedState FlowControl
- replacePat :: SedState FlowControl
- appendPat :: SedState FlowControl
- replaceHold :: SedState FlowControl
- appendHold :: SedState FlowControl
- insert :: ByteString -> SedState FlowControl
- test :: Maybe Label -> SedState FlowControl
- substitute :: ByteString -> ByteString -> Flags -> SedState FlowControl
- next :: SedState FlowControl
- list :: SedState FlowControl
- exchange :: SedState FlowControl
- appendLinePat :: SedState FlowControl
- printPat :: SedState FlowControl
- writeUpPat :: SedState FlowControl
- quit :: SedState FlowControl
- transform :: ByteString -> ByteString -> SedState FlowControl
- writeF :: FilePath -> SedState FlowControl
- readF :: FilePath -> SedState FlowControl
- printPatSpace :: SedState ()
- isLastLine :: SedState Bool
- prnStr :: ByteString -> SedState ()
- prnStrLn :: ByteString -> SedState ()
- prnChar :: Char -> SedState ()
- prnPrintf :: Char -> SedState ()
Documentation
data FlowControl Source
processFiles :: [FilePath] -> SedEngine ()Source
Process the input text files
jump :: [SedCmd] -> Maybe Label -> [SedCmd]Source
Transfer control to the command marked with the label
line :: SedState (Status, ByteString)Source
Read an input line
execCmd :: SedCmd -> SedState FlowControlSource
Execute the Sed function if the address is matched
matchAddress :: Address -> SedState BoolSource
Check if the address interval is matched
runCmd :: SedFun -> SedState FlowControlSource
Execute the Sed function
group :: [SedCmd] -> SedState FlowControlSource
'{cmd...}' Groups subcommands enclosed in {} (braces)
lineNum :: SedState FlowControlSource
'=' Writes the current line number to standard output as a line
append :: ByteString -> SedState FlowControlSource
'a\\ntext' Places the text variable in output before reading the next input line
branch :: Maybe Label -> SedState FlowControlSource
'b label' Transfer control to :label elsewhere in script
change :: ByteString -> SedState FlowControlSource
'c\\ntext' Replace the lines with the text variable
deleteLine :: SedState FlowControlSource
d
Delete line(s) from pattern space
deletePat :: SedState FlowControlSource
D
Delete first part (up to embedded newline) of multiline pattern space
replacePat :: SedState FlowControlSource
g
Copy contents of hold space into the pattern space
appendPat :: SedState FlowControlSource
G
Append newline followed by contents of hold space
to contents of the pattern space.
replaceHold :: SedState FlowControlSource
h
Copy pattern space into hold space
appendHold :: SedState FlowControlSource
H
Append newline and contents of pattern space to contents
of the hold space
insert :: ByteString -> SedState FlowControlSource
'i\\ntext' Writes the text variable to standard output before reading the next line into the pattern space.
test :: Maybe Label -> SedState FlowControlSource
't label' Jump to line if successful substitutions have been made
substitute :: ByteString -> ByteString -> Flags -> SedState FlowControlSource
'spatternreplacement/[flags]' Substitute replacement for pattern
next :: SedState FlowControlSource
n
Read next line of input into pattern space.
list :: SedState FlowControlSource
l
List the contents of the pattern space, showing
nonprinting characters as ASCII codes
exchange :: SedState FlowControlSource
x
Exchange contents of the pattern space with the
contents of the hold space
appendLinePat :: SedState FlowControlSource
N
Append next input line to contents of pattern space
printPat :: SedState FlowControlSource
p
Print the lines
writeUpPat :: SedState FlowControlSource
P
Print first part (up to embedded newline) of
multiline pattern space
quit :: SedState FlowControlSource
q
Quit
transform :: ByteString -> ByteString -> SedState FlowControlSource
'y/abc/xyz' Transform each character by position in string abc to its equivalent in string xyz
writeF :: FilePath -> SedState FlowControlSource
'w file' Append contents of pattern space to file
readF :: FilePath -> SedState FlowControlSource
r
Read contents of file and append after the contents of the
pattern space
printPatSpace :: SedState ()Source
Skip label, comment and empty command
Print the pattern space to the standard output
isLastLine :: SedState BoolSource
Check if the current line in the pattern space is the last line
prnStr :: ByteString -> SedState ()Source
Writes the string to the standard output or save the string in the memory buffer
prnStrLn :: ByteString -> SedState ()Source
The same as prnStr, but adds a newline character