The Translator translates
case-ada/when_ada
structures toif/then/else
structures for simulation and code generation needs:
● Acase_ada
statement selects for execution one of a number of alternativesequences_of_statements
; the chosen alternative is defined by the value of an expression and simply evaluated to anif/then/else
statement. For example:if (expression == key_value1) then actions;
else if(expression == key_value2) then actions;
. . .
● A choice list is translated as sequence ofor
statements in anif/then/else
expression. For example,when_ada 1| 2| 3 => <actions>
translates to:if (expression == 1 || expression == 2 || expression == 3)
then <actions>
● All default action concatenated as sequence of action and run if none of thewhen_ada
statements is chosen.The following table shows the translation of a
case_ada
statement.
case_ada X is
when_ada 1 | 2 => Y++;Y=Y+2;
when_ada 3 => FOO1(Y);
when_ada 4 => FOO2(Y);
when_ada others => DEF_ACTION(X);
end case_ada
if ( (X==1) || (X==2) )
{
Y = (Y + 1);
Y = (Y + 2);
}
else
{
if ( X==3 )
{
FOO1();
}
else
{
if ( X==4 )
{
FOO2();
}
else
{
DEF_ACTION();
}
}
}