The following keywords have special meaning to the interpreter and should not be used as symbols within a program.
- local
- global
- if
- else
- while
- do
- switch
- for
- return
- break
- continue
- case
- default
- int
- float
- string
- trace
- NULL
- EOF
The major components of an interpreter source file are listed below, Each of these may be further subdivided into smaller components. The syntax is described in detail under these headings;
Interpreter source is ceated in glossary files with each subroutine declared within a named glossary entry, where the glossary name is the same as the subroutine's function name with the suffix "()".#function()
subroutine
))
[ ... ]
A subroutine declaration includes a list of symbols (variable_list) matching any arguments passed when the subroutine is called. This declaration is followed by a compound statement.function ( [ variable_list ] ) statement [ ... ]
A compound statement (block) is one or more statements surrounded by "curly" braces. Each instance of a compound statement may include local variable declarations at the top of the block which are only visible to that block or any nested compound statement. (inner block).{ [ declaration ... ] [ statement ... ] }
Variables may be declared at the top of any new compond statement (block). Variables may be declared as either local or global. Local variables are only visible to that block or any nested compound statement. Global variables, once declared are visible to the entire program. Global variables are not declared until they are encountered during program execution.local variable_list ;
global variable_list ;
Each instance of a symbol within a variable_list declares the symbolic name of a variable. All symbols within a block must be unique, but new symbols within a nested block may have indentical names to another variable in an outer block.symbol [ , symbol ... ]
A statement will start with one of the keywords if, else, while, do, switch, for, return, break, continue case or trace. Otherwise it may be a compound statement or an expression. The keywords, do, return, break continue and trace, and any expression must be terminated with a semi-colon.
- if ( expression ) statement [ else statement ]
- while ( expression ) statement
- do statement while ( expression ) ;
- switch ( expression ) compound_statement
- for ( [ expression ] ; [ expression ] ; [ expression ] )
- return [ ( expression ) ] ;
- break ;
- continue ;
- case constant :
- default :
- trace ( expression ) ;
- compound_statement
- expression ;
Expressions without operators may be either a variable, constant or function (sub-routine) call.Expressions are evaluated from left to right. Expressions enclosed in parenthesis (compound expressions) are evaluated separately before being used in the remainder of the expression.
- variable
- constant
- function ( [ argument_list ] )
( expression )Regular expressions may be a unary expression (one operand), binary expression (two operands) or a conditional (ternary) expression with three operands.
The interpreter allows indirect function references. Any instance of a declared function name without an argument list creates a duplicate reference to the named function.- unary_expression
- binary_expression
- ternary_expression
The interpreter supports pre and post increment or decrement. Pre-increment or decrement is only valid with variables.The simple unary expressions; not (logical), ones-complement (bit-wise) and negate (arithmetic) use the exclamation mark, tilde and minus symbols respectively.++ variable -- variable expression ++ expression -- The interpreter allows indirect variable references through "address of" (&) and "contents of" (*) operators, similar to standard C.
- ! expression
- ¯ expression
- - expression
An expression will result in a value of a type determined by the expression. The result may be converted into a particular type by preceding it with a cast.
- & expression
- * expression
- ( int ) expression
- ( float ) expression
- ( string ) expression
Within binary expressions there are several classes of operators. Each allows different types of expressions on either side of the operator. The interpreter supports the following binary expressions;assignment_op
- expression assignment_op expression
- expression arithmetic_op expression
- expression conditional_op expression
- expression bitwise_op expression
- expression string_op expression
- expression compound_aritmetic_op expression
- expression compound_bitwise_op expression
The interpreter supports all standard C operators. The simplest operator is "assignment" which will copy the result of the expression to the right into the expression to the left of the equals symbol (typically a variable).arithmetic_op
- =
The arithmetic operators are add, subtract, multiply, divide and modulus. The operands must both be numeric, and the result will be an integer if both operands are integers, otherwise it will be a float.conditional_op
- +
- -
- *
- /
- %
The conditional operators include the logical operators; OR (||), and AND (&&). The operands must both be numeric or any other type and NULL, and the result will be an non-zero integer if true or zero if false.bitwise_op
- >
- <
- >=
- <=
- ==
- !=
- ||
- &&
The bit-wise operators operate on integers only and include right/left shift, boolean OR, AND, and exclusive OR (XOR).string_op
- >>
- <<
- |
- &
- ^
The plus symbol may be used for concatenation of string variables, and the conditional operators are used for string comparison.
- +
- -
- >
- <
- >=
- <=
- ==
- !=
If the right hand expression in a string concatenation operation is an integer constant, the single character represented by the integer constant will be appended to the left hand string expression. The minus symbol is used for string comparison whereby a negative, zero or positive result is returned depending upon whether the first string is leass than, equal to or greater than the second respectively.compound_arithmetic_opThe compound aritmetic operators include all the arithmetic operators followed by an assignment operator;compound_bitwise_op
- +=
- -=
- *=
- /=
- %=
The compound bitwise operators include all the bitwise operators followed by an assignment operator;
- >>=
- <<=
- |=
- &=
- ^=
The ternary expression uses a conditional operator, the second or third expression will be evaluated depending upon the condition of the first;
Different data types are represented as constants using differing notation. The recognised constants are; integer_constantAn integer constant may either be a single character, or a decimal, octal or hexadecimal integer. Each use standard C constant notation;float_constantcharacter e.g.'A'
'\n'decimal e.g.1234
100
0octal e.g.0377
017700hexadecimal e.g.0xff
0XAAAAA floating point constant is a numeric string containing a decimal point and an optional exponent.e.g.string_constant12.345
0.12345e6
0.123456E-5A string is any string surrounded by double quotes. The string may also include control character notation using a carat (^), and octal charater notation where a backslash precedes a numeric string of up to three characters. These two examples are the same; e.g.error_constant"\007Error!!!"The backslash may also precede specific characters to represent common control codes such as newline (\n), return (\r), tab (\t). The backslash character otherwise removes special meaning of any other character; e.g.
"^GError!!!""The quick brown dog\n"
"Press \"Insert\" key"
The NULL constant is often used to test for uninitialised variables or error return values from functions and subroutines. The EOF constant is used to test for an error return value from several file functions.array_constant
- NULL
- EOF
Array constants consist of a comma separated list of constants surrounded by curly braces. Multi-dimension array constants are declared by nesting array constants.{ constant [ , constant ... ] }
Function and subroutines are referenced by their symbolic name. User defined functions are declared as subroutines in the source code.symbolFunctions must also be declared within a local or global declaration where they are to be used in an indirect reference with the program. In this case they will be suffixed with brackets to identify them as function declarations. i.e.local function();Any other instance of a function symbol followed by a bracketed argument list in the program will invoke a subroutine call to that function. i.e.function ( argument_list );Any instance of a declared function symbol without an argument list and braces will yield a duplicate reference to the named function. (i.e. a pointer to a function). e.g.local funct(), fpointer;
fpointer = funct;
fpointer();
Variables are referenced by their symbolic name. Elements of an array variable are referenced by one or more subscript expressions following the symbol enclosed in square brackets.symbol [ [ expression ] ... ]Variables are declared within a variable_list as part of a subroutine function declaration or a local or global declaration, by naming the symbols only. Any other instance of a declared variable symbol within a program will yield the current value and type of the varaible, as will a fully subscripted array variable.A partially indexed, or un-indexed array variable will yield the partial array elements that were indexed, or the entire array if the varaiable is un-indexed.
Function and variable names are symbolic and consist of any string starting with an alpha character or a underscore followed by any combination of alpha-numeric characters. All symbols are case sensitive. These are examples of allowable symbols; e.g.delta_x
x1
_page