Statements

if ( <expression> ) <statement> [ else <statement> ]
while ( <expression> ) <statement>
do <statement> while ( <expression> )
for ( [<expression>] | [var <name-with-initialization>] ; [<expression>] ; [<expression>] ) <statement>
for ( [<name>] | [var <name-with-initialization>] in [<expression>] ) <statement>
switch(<expression>) { case <expression>:<statement> [...] default: <statement> }
break;
continue;
return [ <expression> ] ;
<expression>;
{ <statement>... }
var <name> [= <expression>] [ , ... ] ;
try <statement> catch ( <variable-name> ) <statement> finally <statement>

Expressions

<expression> , <expression>
<lvalue> = <expression>
<lvalue> += <expression>
<lvalue> -= <expression>
<lvalue> *= <expression>
<lvalue> /= <expression>
<lvalue> %= <expression>
<lvalue> &= <expression>
<lvalue> |= <expression>
<lvalue> ^= <expression>
<lvalue> <<= <expression>
<lvalue> >>= <expression>
< expression> ? <expression (if-true)> : <expression (if-false)>
<expression> || <expresssion>
<expression> && <expression>
<expression> | <expression>
<expression> ^ <expression>
<expression> & <expression>
<expression> == <expression>
<expression> === <expression>
<expression> != <expression>
<expression> !== <expression>
<expression> < <expression>
<expression> <= <expression>
<expression> >= <expression>
<expression> > <expression>
<expression> << <expression>
<expression> >> <expression>
<expression> + <expression>
<expression> - <expression>
<expression> * <expression>
<expression> / <expression>
<expression> % <expression>
<expression> instanceof <class-name>
- <expression>
! <expression>
~ <expression>
typeof <expression> // result is a string - name of type of the expression
++ <lvalue>
--<lvalue>
<lvalue> ++
<lvalue> --
new <class-name> ( [ <argument-list> ] )
<expression> ( [ <arguments> ] )
<expression> . <name>
<expression> '[' <expression> ']'
<expression> '[' [<int-expression>] .. [<int-expression>] ']' // slice of the string/array
( <expression> )
<variable-name>
<number-constant>
<string-constant>
<array-constant>
<regexp-constant>
<object-constant>
this
super
null
true
false
undefined

Constants

<numeric-constant> is one of <decimal-number>, <hexadecimal-number> or <char-constant>, where:
<decimal-number> is [sign] decimal digits [. decimal digits] [ {d | D | e | E} [sign] decimal digits ]
<hexadecimal-number> is  0 { x | X } hexadecimal digits
<char-constant> is ' character ' ( character enclosed by apostrophes ) Example: 'a'

<string-constant> is sequence of characters enclosed by double quotes. Example: "hello world"

<array-constant> is '[' [ expression [ , ... ] ] ']'

<object-constant> is '{' [ expression(key) : expression(value) [ , ... ] ] '}'

<regexp-constant> is '/' single line regular expression ['/ig'];

<symbol-constant> is a sequence of alphanumeric characters starting from symbol '#', example: #left.
Symbols are represented internally as integers having unique number in the system.

Functions

Named functions can be declared as:

function <name> ([<parameter-name1> [, <parameter-name2> [, ... <parameter-nameN> ]]])
{
//... function body
}

Anonymous functions can be declared in place without any name like:

var foo = function (parameters) { /* function body */ }

Nested functions (functions inside functions) are allowed.

Classes

TIScript is a prototyped language therefore there is no pure class abstraction in traditional for C++ or Java form.

Classes here are just objects and may be declared/defined by using following template:

var MyClass =
{

classField1: expression,
classField2: expression,
classFieldN: expression,
method1: function ( parameter-list ) { /* method1 body */ },
method2: function ( parameter-list ) { this.method1(); /* example of method call*/ },
method3: function ( parameter-list )
{
this.classField1 = 1; /* example of instance field access*/
this.method2( parameters ) /* call of other istance method */
super.methodOfSuperClass( parameters ); /* call of method of super class, see prototype field */
},
constructor: function ( parameter-list )
{
super(parameters); /* optional call of constructor of super class */
this.instanceField1 = expression; /* creation and intialization of instance field */
this.instanceField2 = expression;
 /* .... other statemnts and no return needed*/
},
prototype: MyOtherClass /* use this optional field to derive this class from some MyOtherClass */

};

constructor here is a predefined name of the method. TIScript runtime calls it to initialize new instance of the class.

To create an instance of such class use operator new:

var instanceOfMyClass = new MyClass( parameters );

This statement will create object variable and call method MyClass.constructor with it.

super keyword is used for invocation of constructor of super class (if used in constructor) or to access to overloaded method/variable.