Omega is a language intended for scripting purposes. Omega is reads `.omega` files which contain Omega-code (specified below), which will then be parsed into bytecode, which can be run instantly, or later through the interpreter.
## Why?
The original version of Omega was written in TypeScript for a NodeJS server for a dungeons and dragons system client. The new server is being written in Rust, so the language must be re-written. To make the process easier, here is the specifications (and technically the documentation) for the re-visited version of the language. To the same repository I will be creating the actual Rust implementation of this language too.
The original version of Omega can be viewed [here](https://github.com/excitedneon/hero.neon.moe/blob/master/ts/omegaParser.ts)
## Who?
Omega is created by [Teascade](https://teasca.de), original version being written with TypeScript in 2016, and new specification and Rust implementation written in 2017.
## License?
Currently Omega has no license, since it is only a specification, but most likely it will be licensed under MIT later.
The general syntax of Omega is fairly similar to that of [TypeScript](https://www.typescriptlang.org/) or [Rust](https://www.rust-lang.org/). The syntax is a mix of [keywords](#keywords) and [expressions](#expressions) displayed such as in the [examples](#examples).
Expressions are a set of [values](#values), [function calls](#function-calls) and [operators](#operators) that Omega interprets and returns a new [value](#values) out of.
Function calls are also very similar to other languages. If there esists a function called `function_one`, it can be called with `function_one();`. If there exists a function called `function_two` which requires two i32's as arguments, it can be called as `function_two(5, 2);` where 5 and 2 are example [integer values](#values).
As is visible in the example, variables defined in the scope are no longer accessible outside the scope. Scopes exist in their individual "environments", where they can access the variables in their upper scopes, but not inner scopes.
Conditions may be simply `true` or `false`, or tests like `var`, where `var` is a `boolean`-type variable, or `name == "test"`, where `name` is a `string`-type variable.
let uninitialized: string; // Initializes this variable as string, but does not give it a value.
let five = 5; // Sets five to 5
let var = "text"; // Sets var to "text"
let five = 6; // Causes an exception, cannot re-define five
five = 3; // (without let-keyword) Re-sets five to 3
```
- Initialization of new variable **must** contain `let`, but re-definition of an existing variable, **cannot** start with `let`.
- The name of the variable being defined must follow the `let` after whitespace.
- After the name of the variable, there _may_ be a definition of the type of the variable, but it is not necassary. When re-defining a value of a variable, there **cannot** be a re-definition of the type.
- If there is no type-definition, an initializing value must be set.
- type-definition's form is as follows: `: T`, and it cannot be preceded by whitespace. between the colon and the `T` there may be whitespace.
- After whitespace, there may be (or must be, if no type-definition is given), an equals`=`-sign, after which there must be more whitespace, after which the [value](#value) of the variable is given.
- After the value of the variable, the `let`-expression **must** end in a semicolon `;`.
#### `def`
Defines a new function or method as follows:
```
def first_function() {
// Code
}
def second_function(param1: string) {
// Code
}
def third_function(param1: i32, param2: string) {
// Code
}
```
- The initialization of the function/method **must** begin with `def`.
- After `def` there must be a number of whitespace, after which the name of the defined function must follow.
- Immediately after the name of the function, there must be an opening parenthesis `(`.
- After the opening bracket there may be parameters listed.
- Format of the parameters follows the [`let`](#let) format, without the `let`-keyword.
- There **must** also be a type-definition.
- There cannot be any default values. (no equals`=`-sign)
- The parameters are divided by a comma`,`, after which there may be any number of whitespace.
- After the list of parameters there **must** be a closing bracket `)`.
- Between the parenthesis and the parameter-lists, there may be any number of whitespace.
- After the `while`, there can be a number of whitespace, after which there **must** be parenthesis, within which (like parameters are in `def`), there must be a `boolean` [value](#values) or otherwise known as a [condition](#conditions).
- After the parenthesis there must be a [scope definition](#scopes).
- The first part (`let i = 0` in this example) is the beginning-expression. It can be any expression, and it will be executed as the loop begins weather or not the scope inside the loop will be accessed.
- The second part (`i <10`inthisexample)istheconditiondefiningweathertheloop-scopewillbeaccessedornot.
- The third part (`i++` in this example) is the step-expression, which will be executed after each execution of the loop-scope.