-
Notifications
You must be signed in to change notification settings - Fork 35
Language Specification
A brief of Language Specification of ReoScript.
- Expression
- Statement
- Expression Statement
- Block
An expression contains Mathematical operations, variable assignment, function calling and etc. Expression should not end with semicolon:
1 + 2 + 3
a = 10
func()
Expression can be nested within '(' and ')':
func() * (1 + 2)
Expression could not be executed directly, it should be contained by Statement or Expression Statement.
Statement is language control syntax, commonly it indicates that what the code should be executed in what cases. The following statements are available in ReoScript:
- if else
- for, while
- switch
- break, continue, return
- try catch finally
e.g.
if (1 + 1 == 2) a = 3;
See Statements.
Expression Statement contains an assignment statement, unary expression and etc. Usually that means an expression it could finish a whole operation without other descriptions. Expression Statement should end with semicolon:
a = 10; // assignment expression
func(1, 2); // function calling expression
return false; // terminal expression
Syntax of Assignment Expression:
identifier = assignment-expression [= assignment-expression]*
Syntax of Function Call:
identifier ( [expression [, expression]* )
Unary Expression is one of following expression:
i++ // post-self-increment-expression, equals i = i + 1, calc after accessing
++i // pre-self-increment-expression, equals i = i + 1, calc before accessing
-i // minus operation
~i // binary operation, bitwise not
new expression // create instance (where expression should be function)
typeof expression // retrieve type of object
Statement and Expression Statement grouped in one scope within '{' and '}' is called Block:
{
a = func() * (1 + 2);
console.log(a);
}
Note: Same as ECMAScript/JavaScript, there is no variable scope according to block level in ReoScript.
if (true) {
var a = 10;
}
console.log(a);
The result is:
10
3 internal types of data are managed and processed in ReoScript.
- Primitive type (null, number, boolean, string, object, function)
- ObjectValue
- .Net Objects (available with DirectAccess)
ReoScript uses standard ECMAScript/JavaScript data types and wrapper objects.
- Object
- String
- Function
- Boolean
- Number
- Array
- Date
- Error
See more details about wrapper object.
- [How to run script in .Net program](How to use ReoScript to run JavaScript)