apiUi – Script grammar

 

Grammar

[ DeclarationList ] [ StatementList ]

 

An activator consists of a list of declarations (optional), followed by an arbitrary number of executable statements.

 

DeclarationList

( Declaration )…

 

Every declaration is terminated by a semicolon.

 

Declaration

Type FieldId [ := Expression ] ‘;’

 

A declaration starts with a type specifier and is followed by an identifier. Like with C it is possible to immediately assign a value to a field by specifying an expression.

 

Example

 

timestamp ws.CurrentTime := now ();

 

Type

FLOAT | INTEGER | STRING | TIMESTAMP

 

A type is a name for a kind of data. The following table lists the supported datatypes in a declaraction within an activator.

 

FLOAT

A float can contain data that can be represented with floating point notation

INTEGER

Integer data is a subset of float data, only whole numbers can be represented

STRING

A string datatype is used to store a sequence of characters

TIMESTAMP

Use timestamp if you want a local field to temporarily store a date, a time or a datetime value

 

 

StatementList

( Statement )…

 

As with C and Pascal, statements are terminated with a semicolon

 

Statement

( Assignment  | CompoundStatement | IfStatement | WhileStatement | VoidStatement ) ‘;’

 

There are five basic statements in the activator language. A CompoundStatement is merely a group of statements enclosed with a begin and end

 

CompoundStatement

‘{’ StatementList ‘}’ | BEGIN StatementList END

 

Examples

 

begin

  ws.begin := 1;

  ws.end := 2;

end

 

{

  ws.begin := 1;

  ws.end := 2;

}

 

IfStatement

IF Expression THEN Statement [ ELSE Statement]

 

Expression returns a Boolean value. If expression is True, then the first statement is executed; otherwise the second statement is executed

 

Examples

 

if ws.salary > 1000 then

  ws.salary := ws.salary * 1.01;

 

if ws.salary > 1000 then

  ws.salary := ws.salary * 1.01;

else                                                                        

begin

  ws.salary := ws.salary + 10;

  ws.salary := ws.salary * 1.01;

end

 

WhileStatement

WHILE Expression DO Statement

 

The While statement executes Statement repeatedly. Before each iteration the Boolean expression is tested. Statement is only executed if Expression returns True.

 

Example

 

while ws.loop > 0 do

{

  ws.count := ws.count + 1;

  ws.loop := ws.loop – 1;

}

 

VoidStatement

Statement that does not return a value such as an embedded sql statement

Assignment

FieldId ‘:=’ Expression

 

An assignment replaces the value of the variable with the value of the expression.

 

Examples

 

ws.loop := 10;

ws.count := ws.loop * 25;

 

Expression

AndExpression [ OR AndExpression ] …

 

AndExpression

RelationalExpression [ AND RelationalExpression ] …

 

RelationalExpression

SimpleExpression [ RelOperand  SimpleExpression ] …

 

SimpleExpression

['+' | '-'] Term [AddOperand Term] …

 

Term

Factor [MulOperand Factor] …

 

Factor

FieldId | Number | String | NOT Factor | ‘(’ Expression ‘)’ | Function ‘(’ [Expression [‘,’ Expression] … ] ‘)’

 

RelOperand

'<' | ‘<=’ | '>' | ‘>=’ | ‘=’ | ‘<>’

 

AddOperand

'+' | ‘-’

 

MulOperand

'*' | ‘/’ | MOD | ‘^’

 

FieldId

[Identifier ’.’]… Identifier ’.’ Identifier

 

Identifier

<identifier>

 

Number

Literal presenting a number

String

Literal enclosed in single quotes representing a string of characters