Hsed-0.2.1: Stream Editor in Haskell

Portabilitynon-portable
Stabilityexperimental
Maintainervirukav@gmail.com

Hsed.StreamEd

Description

The Sed runtime engine. The execution sequence includes the parseArgs compile (parse) and execute Sed commands.

Synopsis

Documentation

data Status Source

Constructors

EOF 
Cont 

Instances

data FlowControl Source

Constructors

Next

Apply the next sed command from the script to the pattern space

Break

Read the new line to the pattern space and apply sed script

Continue

Reapply the sed script to the current pattern space

Goto (Maybe ByteString)

Jump to the marked sed command and apply it to the pattern space

Exit

Quit

runSed :: [FilePath] -> String -> Env -> IO EnvSource

Compile and execute the sed script

compile :: String -> SedState ()Source

Parse the Sed commands

execute :: [FilePath] -> SedState ()Source

Execute the parsed Sed commands against input data

processStdin :: SedState ()Source

The standard input will be used if no file operands are specified

processFiles :: [FilePath] -> SedState ()Source

Process the input text files

loop :: [SedCmd] -> SedState ()Source

Cyclically append a line of input without newline into the pattern space

line :: SedState (Status, ByteString)Source

Read an input line

eval :: [SedCmd] -> SedState FlowControlSource

Manage the flow control of the Sed commands

goto :: [SedCmd] -> Maybe Label -> [SedCmd]Source

Transfer control to the command marked with the label

execCmds :: [SedCmd] -> SedState FlowControlSource

Execute Sed commands

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

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

prnChar :: Char -> SedState ()Source

The same as prnStr, but for char

prnPrintf :: Char -> SedState ()Source

Print the character as three-digit octal number