Production: Calculator1

Top  Previous  Next

Examples > Calculator > Production: Calculator1

 

The start rule for the Calculator1 program is:

 

 

{{double d;}}

Expression[d]

{{out << d << "\n";}}

 

In this example the actions are included into the double braces  {{...}}. For such actions special project options are valid. These options determine, whether the actions are interpretable inside of the TextTransformer or not. For this project the default value is maintained, that means: they are interpretable.

 

The action:

 

double d;

 

declares a variable of the type double, which shall take the result of the calculation.  Variables of this type can contain numbers with fractional digits.

 

The action:

 

out << d << "\n";

 

already is know from the previous examples. The value of the variable followed by a line break will be written into the output.

 

Between the just explained two actions the production Expression is executed.

Inside of this production, the result is calculated. By means of the bracket "[d]" in

 

Expression[d]

 

the variable d is passed to the Expression production, where it can get its value.

 

 



This page belongs to the TextTransformer Documentation

Home  Content  German