Script language grammar – Multi-Tech Systems MTASR1-100 User Manual
Page 201

Appendix B - Script Language
201
Script Language Grammar
proc a;
integer t;
/*Some more code here. */
t=b(x,y);
/*Some more code here. */
return(t);
endproc
proc b;
return(a(u,v);
endproc
Argument to procedures can be passed by value or address. To pass an argument by address, prefix the
argument name in the formal parameter list by the keyword VAR; otherwise the argument is passed by value.
Only variables can be passed by address. Expressions like A+B, where A and B are integer variables can be
passed by value but cannot be passed by address.
Two basic types of variables are supported:
INTEGER and STRING
In the STRING, since the ASCII null character is internally used to indicate the end of the sequence, it cannot
be part of the string. All other characters, including extended ASCII characters can be part of the string.
There are two types of conditional constructs:
IF and SWITCH
The IF statement is a two-way branching construct. The condition can be an arbitrary expression. The
condition in the IF statement should evaluate to an integer or real. If the expression in the IF statement
evaluates to non-zero, the control enters the THEN statement, otherwise control enters the ELSE statement.
The SWITCH statement is a multi-way branching construct. The type of conditional expression should be
either INTEGER or STRING. The value of the conditional expression is matched against the constrants given
in the CASE options, if the value matches a CASE option value, control enters that CASE option. If the values
do not match any of the CASE options, and if a DEFAULT option is provided, control continues at the
DEFAULT option; otherwise control continues at the statement after the ENDSWITCH. If control enters one of
the CASE or DEFAULT statements, all the statements up to the next ENDCASE statement are executed.
Each CASE or DEFAULT statement should be terminated by a matching ENDCASE keyword. The SWITCH
statement should be terminated by a ENDSWITCH keywork. The DEFAULT statement can be placed
anywhere within the scope of the SWITCH statement. There can be only one DEFAULT statement.
There are two types of iterative contructs:
FOR and WHILE
The FOR construct sets the loop control variable to an initial value. The control variable is checked for
bounds, and if within bounds, the
After each execution of
value. This is computed as follows: if the STEP expression is given it is the value of the expression, else it is
1. The control variable is incremented if TO is specified, and is decremented if DOWNTO is specified. After
updating the control variable the bounds check is done again. The keyword ENDFOR is mandatory at the end
of the loop.
The WHILE loop has an expression and a
is non-zero the
ENDWHILE is mandatory at the end of the loop.
Operator Precedence:
Operators are listed in the order of precedence
Unary Operators :-!(unary minus, logical negation)
Binary Operators :*/ + _< > <= >= == ! = && II
All the operators are left associative. Expressions are evaluated completely; so care must be taken while
writing expressions. For example, expressions like (a !=0 && b / a) would create run time error.