| Portability | non-portable |
|---|---|
| Stability | experimental |
| Maintainer | virukav@gmail.com |
Hsed.Ast
Description
The main types used in the program
- data SedCmd = SedCmd Address SedFun
- data SedFun
- = Group [SedCmd]
- | LineNum
- | Append Text
- | Branch (Maybe Label)
- | Change Text
- | DeleteLine
- | DeletePat
- | ReplacePat
- | AppendPat
- | ReplaceHold
- | AppendHold
- | Insert Text
- | List
- | NextLine
- | AppendLinePat
- | PrintPat
- | WriteUpPat
- | Quit
- | ReadFile FilePath
- | Substitute Pattern Replacement Flags
- | Test (Maybe Label)
- | WriteFile FilePath
- | Exchange
- | Transform Text Text
- | Label Label
- | Comment
- | EmptyCmd
- data Addr
- = LineNumber Int
- | LastLine
- | Pat Pattern
- data Address = Address (Maybe Addr) (Maybe Addr) Invert
- data Occurrence
- = Replace Int
- | ReplaceAll
- type OutputPat = Bool
- data OccurrencePrint
- data Flags = Flags (Maybe OccurrencePrint) (Maybe FilePath)
- type Replacement = ByteString
- type Invert = Bool
- type Text = ByteString
- type Label = ByteString
Documentation
Functions represents a single-character command verb
Constructors
| Group [SedCmd] | { - group of the sed commands |
| LineNum | = - write to standard output the current line number |
| Append Text | a - append text following each line matched by address |
| Branch (Maybe Label) | b - transfer control to Label |
| Change Text | c - replace the lines selected by the address with Text |
| DeleteLine | d - delete line(s) from pattern space |
| DeletePat | D - delete (up to newline) of multiline pattern space |
| ReplacePat | g - copy hold space into the pattern space |
| AppendPat | G - add newline followed by hold space into the pattern space |
| ReplaceHold | h - copy pattern space into hold space |
| AppendHold | H - add newline followed by pattern space into the hold space |
| Insert Text | i - insert Text before each line matched by address |
| List | l - list the pattern space, showing non-printing chars in ASCII |
| NextLine | n - read next line of input into pattern space |
| AppendLinePat | N - add next input line and newline into pattern space |
| PrintPat | p - print the addressed line(s) |
| WriteUpPat | P - print (up to newline) of multiline pattern space |
| Quit | q - quit when address is encounterd |
| ReadFile FilePath | r - add contents of file to the pattern space |
| Substitute Pattern Replacement Flags | s - substitute Replacement for Pattern |
| Test (Maybe Label) | t - branch to line marked by :label if substitution was made |
| WriteFile FilePath | w - write the line to file if a replacement was done |
| Exchange | x - exchange pattern space with hold space |
| Transform Text Text | y - transform each char by position in Text to Text |
| Label Label | : - label a line in the scipt for transfering by b or t. |
| Comment | |
| EmptyCmd |
|
An address is either a decimal number that counts input lines cumulatively across files,
a $ character that addresses the last line of input, or a context address as BRE
Constructors
| LineNumber Int | |
| LastLine | |
| Pat Pattern |
A permissable address is representing by zero, one or two addresses
data Occurrence Source
Used in the replacement string. An appersand (&) will be replaced by the
string matched the BRE. The characters n, where n is a digit will be
replaced by the corresponding back-reference expression.
Constructors
| Replace Int | |
| ReplaceAll |
Instances
data OccurrencePrint Source
The allowed sequence of the Occurrence and OutputPat flags in the substitute function
Constructors
| OccurrencePrint (Maybe Occurrence) OutputPat | |
| PrintOccurrence OutputPat (Maybe Occurrence) |
Instances
Flags used in the substitute command
Constructors
| Flags (Maybe OccurrencePrint) (Maybe FilePath) |
type Replacement = ByteStringSource
type Text = ByteStringSource
type Label = ByteStringSource