Skip to content

Language Specification

Jing Lu edited this page May 24, 2013 · 52 revisions

A brief of Language Specification of ReoScript.

Language Elements

  • Expression
  • Statement
  • Expression Statement
  • Block

Expression

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

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:

e.g.

if (1 + 1 == 2) a = 3;

See Statements.

Expression Statement

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

Assignment Expression

Syntax of Assignment Expression:

identifier = assignment-expression [= assignment-expression]*

Function Call

Syntax of Function Call:

identifier ( [expression [, expression]* )

Unary 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

Block

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

Data Types

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)

Primitive type

Object Value

ReoScript uses standard ECMAScript/JavaScript data types and wrapper objects.

  • Object
  • String
  • Function
  • Boolean
  • Number
  • Array
  • Date
  • Error

See more details about wrapper object.

See Also

  • [How to run script in .Net program](How to use ReoScript to run JavaScript)

Clone this wiki locally