A statement as defined by the sed language -- except for branches and labels which are not supported. More...
#include <muSED.h>
Public Member Functions | |
LineRangeActivationState | activationState () |
void | adoptChild (Statement *newbie) |
Take ownership of a new statement and schedule it for delete when *this is destructed. | |
void | clear () |
std::string | debugPrefix () const |
virtual std::string | debugString () const |
virtual bool | execute (ScriptRuntimeContext *context)=0 |
Execute this statement on the specified context. | |
void | setActivationState (LineRangeActivationState newState) |
Statement (Statement *parentStatement) | |
virtual | ~Statement () |
Static Public Member Functions | |
static void | debugPrint (Statement *p) |
Public Attributes | |
ActivationMap | childStatementActivationMap_ |
std::list< Statement * > | childStatements_ |
Statement * | parentStatement_ |
A statement as defined by the sed language -- except for branches and labels which are not supported.
A sed script is a collection of sed language statements which will all be applied to all input lines from a stream -- unless those statements are suppressed by a line selection filter. In muSED, branches and labels are not supported, nor is the test command which is a variant of the branch command.
The goal of a sed script is to transform an input stream of lines to an output stream of lines. In the program "sed", the default logic is to copy stdin to stdout without modifcation, but in muSED, the default logic is to delete the stream and produce no output. All desired output must be produced using the 'p' command to print the current pattern buffer (ie the most recently read input line) to it's output location. Thus, the following is the do nothing script in muSED:
p
sed Statements have an optional prefix and statement body.
The prefix contains 0, 1, or 2 filters used to decide if the statement should be executed on the current input line.
0 selection filters mean that the statement body applies to all lines to be processed.
1 filter prefix means that the statement body applies ONLY to lines that match the filter.
2 filter prefixes define a range of lines. The body is applied to all lines from the first line that matches the first filter to the first line that matches the second filter. The command will be applied to all ines in the range. You can use a nested command with its own filter to avoid having the command applied to the last line.
filters look basically like this:
<filterExpression>[!]
That is, any single filter can have it's logic inverted by simply appending!. For example, the filter that selects only line 12, looks like this:
12
To select all lines BUT 12, do this:
12!
statement bodies include primary command characters and parameters
s -- string substitute p -- copy the current pattern buffer to the output sequence (i.e. "print" it) P -- print the leading fragment of the current input line, up to the first \\n (which could only have gotten into that line if you had done a G to append hold to pattern, or if you had done an x to swap hold and pattern after having done an H). d -- print the current line and stop processing it. D -- stop processing this input line without printing it q -- print the current input line and process no more lines Q -- do not print the current input line and process no more lines h -- copy pattern to hold H -- append the pattern buffer to the hold buffer (\\n is the delimiter) g -- replace the pattern buffer with the hold buffer G -- append the hold buffer to the pattern buffer with \\n as a delimiter x -- swap the pattern and hold buffers
Definition at line 319 of file muSED.h.
virtual ~Statement | ( | ) | [virtual] |
LineRangeActivationState activationState | ( | ) |
void adoptChild | ( | Statement * | newbie | ) |
std::string debugPrefix | ( | ) | const |
static void debugPrint | ( | Statement * | p | ) | [static] |
virtual std::string debugString | ( | ) | const [virtual] |
Reimplemented in OuterStatement, BlockStatement, SubstStatement, TranslateStatement, PrintStatement, SwapStatement, DeleteStatement, QuitStatement, HoldStatement, and GetStatement.
Definition at line 469 of file muSED.h.
virtual bool execute | ( | ScriptRuntimeContext * | context | ) | [pure virtual] |
Execute this statement on the specified context.
Implemented in OuterStatement, BlockStatement, SubstStatement, TranslateStatement, PrintStatement, SwapStatement, DeleteStatement, QuitStatement, HoldStatement, and GetStatement.
void setActivationState | ( | LineRangeActivationState | newState | ) |
std::list<Statement *> childStatements_ |