Top  Previous  Next

Scripts > Class elements and c++ instructions > Interpreted C++ instructions > Output > out


out represents the target text: inside of the IDE working space this text appears in the target window. In the Transformation-Manager or the command line tool and the generated c++ parser, the target text is written into a file. To write a text or the content of a variable to out, the shift operator  "<<" is used.




May sResult be a string variable, which holds the text "42", the following instruction:


out << sResult;


causes the appearance of  "42" in the target window. Shift instructions can be chained:


out << "The result is: " << sResult << "\n";


This chain of instructions writes


"The result is: 42" 


into the target window. (The character '\n' represents a line feed. When this character is written to out, the next output will be written into the next line. ) 


The result of a call of a production or a token, which returns a value, can be written to the output directly. For this, the closing bracket of the semantic action must follow the shift operator directly and the bracket must be followed by the call of the rule. Example:


{{ out << }} Rule




Remark 2: The output to out can be redirected into another file by RedirectOutput.


Remark 3: If c++ code is generated, out is replaced by the expression: xState.out(). xState.out() returns an ostream object from the plugin.





out << endl


is another notation for


out << '\n'


In c++ this command also flushes the output buffer.


Remark: Up to the version of the TextTransformer cout had to be written instead of out. cout represents the standard output channel, normally the console.

This page belongs to the TextTransformer Documentation

Home  Content  German