Actions

Top  Previous  Next

Examples > Conversion of an Atari text > Actions

 

Like in the first example a semantic action is executed after each recognized text section (character), which writes some text into the output.

 

The text, which is recognized by the normal_text (SKIP) token, simply will be copied:

 

{{ out << xState.str(); }}

 

Special characters will be translated into readable characters, e.g:

 

| ue   {{ out << "ü"; }}

 

For the text attributes however, there are no semantic actions defined. So these attributes simply are ignored. Every word processing program has its own way to code these attributes in its text documents. As an example a conversion into the RTF format is discussed below.

 

What shall be made with the recognized sections of text, is written in the productions inside of the pair of brackets "{=" and =}". Here the so-called semantic actions are defined. In the tree view they are represented by nodes, the names which of begin with "Sem"; e.g. Sem0_of_Alt0_of_Rep0_of_Atari .

 

The instructions for the semantic actions are a subset of the programming language c++.  For the Atari project only one instruction is needed: the shifting of a text into the output.

 

For example, the production special_char contains the line:

 

| ue   {= out << "ü"; =}

 

This means: as soon as the symbol ue is recognized, execute the action

 

out << "ü";

 

that means append the text "ü" at the target text. The semantic actions, which are executed after the recognition of the other tokens, are similar.

 

For the text attributes however, there are no semantic actions defined. So these attributes simply are ignored. Every word processing program has its own way to code these attributes in its text documents. As an example a conversion into the RTF format is discussed below.

 

 

If you now execute the program, the part of text shown at the beginning now looks:

 

 

AtariOutput

 

The text attribute characters are removed and an "ü" replaced the empty square "".



This page belongs to the TextTransformer Documentation

Home  Content  German