LANGUAGE SYNTAX


Keywords

The  following  keywords have special meaning to the  interpreter  and should not be used as symbols within a program.


Syntax Description

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;


Source file structure

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
))
[ ... ]


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 [ ... ]


compound_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 ... ] }


declaration

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 ;


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 ... ]


statement

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.


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.
( expression )
Regular  expressions  may be a unary expression (one operand),  binary expression  (two operands) or a conditional (ternary) expression  with three operands.


argument_list


unary_expression

The  interpreter  supports  pre  and   post  increment  or  decrement. Pre-increment or decrement is only valid with variables.
  • ++ variable
  • -- variable
  • expression ++
  • expression --
  • The   simple  unary  expressions;   not   (logical),   ones-complement (bit-wise) and negate (arithmetic) use the exclamation mark, tilde and minus symbols respectively. The   interpreter   allows  indirect   variable   references   through "address of"  (&) and "contents of" (*) operators, similar to standard C. 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.


    binary_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
    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_op
    The  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;


    ternary_expression

    The  ternary  expression  uses a conditional operator, the  second  or third expression will be evaluated depending upon the condition of the first;


    constant

    Different  data  types  are represented as constants  using  differing notation. The recognised constants are; integer_constant
    An  integer  constant may either be a single character, or a  decimal, octal or hexadecimal integer. Each use standard C constant notation;
    character e.g.
    'A'
    '\n'
    decimal e.g.
    1234
    100
    0
    octal e.g.
    0377
    017700
    hexadecimal e.g.
    0xff
    0XAAAA
    float_constant
    A  floating  point constant is a numeric string containing  a  decimal point and an optional exponent.e.g.
    12.345
    0.12345e6
    0.123456E-5
    string_constant
    A  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.
    "\007Error!!!"
    "^GError!!!"
    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.
    "The quick brown dog\n"
    "Press \"Insert\" key"
    error_constant
     
    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
    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

    Function  and subroutines are referenced by their symbolic name.  User defined functions are declared as subroutines in the source code.
    symbol
    Functions  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();


    variable

    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.


    symbol

     
    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