Go to the first, previous, next, last section, table of contents.
The syntax of the language is discuss under the following headings...
The lexical syntax which is the form of individual words, keywords and tokens. Non
formal grammar, which is a informal chatty description of the various grammatical sections
and statements. And finally the formal Backus-Naur-Format grammar for the language. One
should remember that the final, exact, precise and last word on the language grammar is
given in the files lexscan.l
and rule.y
.
The language is completely case insensitive. All input is translated into lowercase characters before processing.
Comments are represented in several ways... In Pascal style using braces
{This is a comment.}
In C style using /*...*/
/* This is also a comment */
And finally in C++ style using //... Everything after the //
until the end
of the line is a comment.
this.is := not a comment; // But this is a comment but.this := is not a comment;
The following words are keywords in the language and should not be used for identifiers or specie names.
IF, THEN, ELSE, ENDIF, RUNNING, RULES, AND, OR, NOT, MOD, SPECIE, END, XOR, DIV, CELLS, LINK, FROM, TO, CELL, BASED, ECOSYSTEM, WIDE, ALL, ANY, ADJACENT, IN, DECLARE, SHOW, PRINT, TRACE
The following tokens are use by the language.
+= Increment -= Decrement + Addition - Subtraction or Unary negate / Real number division ; Statement separator , Argument separator := Becomes (or assignment operator) > Greater than >= Greater than or equal to (GE) < Less than <= Less than or equal to (LE) = Equals (Comparison operator, not to be confused with := the assignment operator) != Not equal (NE) ! Not % Mod. (Exactly equivalent to keyword MOD) [ Start range argument list ] End range argument list. @ Cell name specifier.
A rules file has the following sections...
This is a list of all the cells within your ecosystem.
cells north_cell, south_cell, east_cell;
This is a list of links between cells. Cells that are directly linked are said to be adjacent.
link north_cell, east_cell; link east_cell, south_cell;
These statements tell the program where to find the input data file and where to write the result to.
input from "mydata.txt"; output to "result.out";
The statements (See See section Statements) in this section are execute once at the start of the program and enable you to set various variables. For example :- To set the model time step to one month...
step_size := 365.25 / 12 * 86400.0; // Units of time are seconds.
A specie declaration defines the rules to be applied to each specie. And consists of the following subsections :-
specie hairy_twit_bird; // This bird is always happy declare optimal; hairy_twit_bird := 2; running rules; optimal := garbage in [-infinity, infinity]; if optimal then hairy_twit_bird += 1; endif; end specie;
For more infomation see...
A specie declaration defines the rules to be applied to each specie. And consists of the following subsections :-
There are two flavours of specie, cell based species like plants, and ecosystem wide species like flamingo. The default flavour is cell based, all though you can be explicit if you like...
cell based specie mullet;
is exactly the same as...
specie mullet;
And declares a specie called mullet, that will be modelled on a cell by cell basis. It
actual produces for each cell an identifier of the form mullet@cellName
.
However, a specie header like so ...
ecowide specie flamingo;
Declares a specie flamingo
that is modelled once for the whole ecosystem
and is not modelled on a cell by cell basis.
With the declare
keyword, you can create variables for use within the
specie rules. For example...
specie mullet; declare fingerlings, optimal;
This creates two identifiers for each cell of the form mullet.fingerlings@cellName
and mullet.optimal@cellName
For ecowide species...
ecowide specie flamingo declare niceAndSalty;
creates a identifier of the form flamingo.niceAndSalty
This creates local variables to hold one double precision number, which can be used within the rules as follows...
specie mullet; declare fingerlings, optimal; fingerlings := 2; running rules; fingerlings += 2; // Add 2 to fingerlings optimal := concentration in [25, 40];
Note that there is one and only one data type in this language and that is double precision floating point numbers. See See section The Boolean convention
Every specie may have some start-up statements (See section Statements) to initialize things.
The statements between the specie header and running rules;
statement are
execute once for each cell at the start of the program.
The statements between the specie header and running rules;
statement are
execute once at the start of the program.
All statements See section Statements between the keywords running rules;
and end specie
are the running rules.
For a cell based specie :-
For each time step, For each cell, All the statements within the running rules are executed.
For a ecowide specie :-
For each time step, All the statements within the running rules are executed.
The keywords end
specie
must terminate every specie declaration.
Go to the first, previous, next, last section, table of contents.