Using tokens

Top  Previous  Next

Examples > Exchange of words > Using tokens

 

The Exchange project contains a second production: Exchange_Token.

Exchange_Token is an alternative possibility to program the exchange of words.

In this version the words, which shall be exchanged, are defined on the token page, where they can be combined directly with actions.

 

On the token page a token GOD can be defined as follows:

 

 

ExchangeTokenGod

 

 

The connected action in the lower field will be executed automatically, as soon as the expression "God" is recognized. With the analogous token for "man" the original production now is simpler:

 

Exchange_Token =

(

GOD

| MAN

| SKIP

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

)+

 

To execute the new production, you have to go to the Tetra page again and you have to choose Exchange_Token as start rule in the box of the tool bar:

 

Exchange_Startrule

 

Than you can use the single node button as explained above.

 

The presentation of the production in the syntax tree has become now more easy too, because the actions are not depicted any longer_

 

ExchangeExchangeTree2_en

 

 

It is a matter of taste, which version of the exchange project you prefer in such a simple example as presented here. In more complex projects, it can be advantageous, to immediately connect a token with an action. The token then can appear in different rules, but the action remains the same.

 

 



This page belongs to the TextTransformer Documentation

Home  Content  German