RouteFinder MTASR1-100 User Guide
Appendix B - Script Language
The script file can be used to automate certain operations. The script file is a text file containing a sequence of commands. The structure of a script file is succinctly expressed by the following grammar.
Script Language Grammar
<program> | =<declarations> <proc_declarations> | |
<declarations> | ={<var_type> <identifier> {, <identifier> } ; } | |
<var_type> | =INTEGER I STRING | |
<statement_list> | ={<statement>} | |
<statement> | =<elementary_statement> I <if_statement> I<for_statement> I | |
|
| <while_statement> I <switch_statement> |
<if_statement> | =IF <expression> THEN <statement_list> {ELSE<statement_list> } ENDIF | |
<for_statement> | =FOR <identifier>=<expression> TO IDOWNTO <expression} STEP | |
|
| <expression> / DO <statement_list> ENDFOR |
<while_statement> | =WHILE <expression> DO <statement_list> ENDWHILE | |
<switch_statement> | =SWITCH <expression> {CASE <integer_const> <statement_list> I | |
|
| CASE <string_const> <statement_list> I |
|
| DEFAULT <statement_list> } |
|
| ENDSWITCH |
<elementary_statement> | =<identifier> = <expression> ; I <identifier> / (<expression> | |
|
| {,<expression> } ) /; I GOTO <identifier> ; I <identifier> : I ; |
<expression> | =<expression> OPERATOR <expression> I {<expression> } I /<expression>I | |
|
| - <expression> I<identifier> / (<expression> {, <expression> } ) / |
OPERATOR | = < I <= I > I >= I == I != I && I II I + I - I * I / I ! | |
<proc_declaration> | =PROC <identifier>/(<parameter_list>)} { :<vartype> };FORWARD ; | |
<proc_declaration> | =PROC <identifier>/(<parameter_list>)} / : <vartype> / ; | |
|
| <declarations> <statement_list>ENDPROC |
<parameter_list> | =<argument_list> { ; <argument_list>} | |
<argument_list> | ={VAR} <var_type> <identifier> {<identifier>} |
Execution starts at the PROC main. PROC main cannot have any arguments. All the variables have to be declared before use. All procedures must be declared before calling. Recursion is allowed in procedures.
To define mutually recursive procedures, use the FORWARD directive to indicate that the procedure body is defined later in the source file. Procedures defined with the FORWARD directive should have all the parameters and return value (if any) specified, the actual definition of the procedure body should not contain the formal parameter list or the return value. An example of forward defined procedures is given below:
proc a(integer x,y) : integer,forward:
proc b(integer u,v) : integer,forward: 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
58 |
|