Productions: block, outer_block

Top  Previous  Next

Examples > Guard > Productions: block, outer_block


The outer_block production describes the body of a function.

The code of a c++ function can be extended over many lines and contain complicated nested structures. For the aim of the current project this is irrelevant. It is important only, to find the insertion positions.

The idea is, that for every closing brace there is a corresponding opening brace. So a block can be described as:









Inside of the pair of braces, there is a sequence of code and sub-blocks. The only difference from the body of a function to a block is, that it's an outer block, not included in a different. The positions after it's opening and before its closing brace are the insertion points, we are looking for. Here the rules print_at_enter and print_at_exit are called, which are used, to write the desired guard functions into the output:



{{ print_at_enter(xState); }}


block   {{ out << xState.lp_copy(); }}

| SKIP    {{ out << xState.copy(); }}



{{ print_at_exit(xState); }}




The option for the testing of all literal tokens must be switched off, as otherwise a token which is needed only in other productions, can be recognized here instead of a SKIP recognition.


The functions print_at_enter and print_at_exit are defined on the element page:


print_at_enter ::=


out << xState.copy() // {

     << "\n  CGuard G(\""

     << m_sScope

     << "\",\""

     << m_sName

     << "\");\n";



Here the variables m_sScope and m_sName are used for the construction of the guard.


print_at_exit ::=


out << "\n  G.stop();\n}";





Here the variables m_sScope and m_sName are cleared.

This page belongs to the TextTransformer Documentation

Home  Content  German