Statement Struct Reference

A statement as defined by the sed language -- except for branches and labels which are not supported. More...

#include <muSED.h>

Inheritance diagram for Statement:
Inheritance graph
[legend]
Collaboration diagram for Statement:
Collaboration graph
[legend]

List of all members.

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_
StatementparentStatement_

Detailed Description

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
Note:
The pattern buffer is the place where the current of input is stored at the beginning of processing. The hold buffer is a second string variable which can be quickly swapped with the pattern buffer. Two buffers are all you get.

Definition at line 319 of file muSED.h.


Constructor & Destructor Documentation

Statement ( Statement parentStatement  ) 

Definition at line 420 of file muSED.h.

virtual ~Statement (  )  [virtual]

Definition at line 454 of file muSED.h.

Here is the call graph for this function:


Member Function Documentation

LineRangeActivationState activationState (  ) 

Definition at line 119 of file muSED.cxx.

Here is the caller graph for this function:

void adoptChild ( Statement newbie  ) 

Take ownership of a new statement and schedule it for delete when *this is destructed.

Definition at line 444 of file muSED.h.

Here is the caller graph for this function:

void clear (  ) 

Definition at line 434 of file muSED.h.

Here is the caller graph for this function:

std::string debugPrefix (  )  const

Definition at line 459 of file muSED.h.

Here is the caller graph for this function:

static void debugPrint ( Statement p  )  [static]

Definition at line 474 of file muSED.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

virtual bool execute ( ScriptRuntimeContext context  )  [pure virtual]

Execute this statement on the specified context.

Returns:
true to indicate that the script should stop immediately.

Implemented in OuterStatement, BlockStatement, SubstStatement, TranslateStatement, PrintStatement, SwapStatement, DeleteStatement, QuitStatement, HoldStatement, and GetStatement.

Here is the caller graph for this function:

void setActivationState ( LineRangeActivationState  newState  ) 

Definition at line 138 of file muSED.cxx.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 416 of file muSED.h.

Definition at line 415 of file muSED.h.

Definition at line 418 of file muSED.h.


The documentation for this struct was generated from the following files:
Generated on Wed Feb 29 22:59:08 2012 for CXXUtilities by  doxygen 1.6.3