Avoid using this instance until migration is complete. For updates and information contact insert#0751

Commit 9d16d934 authored by insert's avatar insert 🎺

Initial commit

parents
# The **Simpl**istic **E**xtensible Language
## Specification
---
### Comments
Inline comments, continues until newline.
```js
// inline comment
```
Mutli-line comments, applies within the tags.
```js
/*
* multi-line comment
*/
```
### Data Types
Type | Example | Description
--------|-----------------|----------------------------------------------------
Bool | `true / false` | Either a truthy or falsey value.
String | `'hello'` | Any characters defined in single or double quotes.
Number | `123` or `1.23` | Either an integer or a float.
#### Number Type [*]
The underlying engine should automatically convert types to allow the number value to go from `-2147483648` to `4294967295`.
### Operators
Operator | Example | Types | Description
----------|---------------|--------|--------------------------------------------
`+` | `5 + 5 // 10` | Any | Adds numbers or concatenates strings.
`-` | `7 - 2 // 5` | Number | Substracts an operand from another.
`*` | `5 * 5 // 25` | Any | Multiplies operands or repeats String by x
`/` | `5 / 5 // 1` | Number | Divides an operand by another.
`!` | `!0 // true` | Any | Gets the opposite of the operand.
#### Silent Addition
Strings / numbers should act as if they have a `+` operator between them.
```js
'hello' 'world'; // helloworld
'my favourite number is ' 2 // my favourite number is 2
5 5 // 10
'5 + 5 is ' 5 5 // 5 + 5 is 55
```
#### Execution Order
Expressions within brackets should be evaluated first.
```js
'5 + 5 is ' (5 5) // 5 + 5 is 10
```
### Variables
Defining a variable.
```js
key = 'value';
```
#### Types
Will be either a `Function` or any of the data types above.
```js
// getting type of variable
key = 'value';
typeof key; // 'String'
```
### Functions
Defining a function, using func keyword and body.
```js
func action {
// function body
}
```
Returning a value, using return keyword.
```js
func name {
return 'tim';
}
```
Defining function with parameters and returning a value.
```js
func add a b {
return a + b;
}
```
#### Calling Functions
Simple function usage, and with paramters.
```js
action;
add 2 5; // 7
```
With arguments list:
```js
add(5 * 2, 10); // 20
```
---
## Lexicon Parsing
---
### Lexicons
There are 19 currently supported lexicons which each implementation should parse.
Lexicon | Type
-----------|------------------------
`a-Z+0-9` | ALPHANUMERIC
SEE BELOW | RESERVED
`0-9+.` | NUMERIC
`* in '"` | STRING
`{}` | BODY (BEGIN / END)
`()` | ARGUMENT (BEGIN / END)
`,` | DELIMETER
`.` | PERIOD
`=` | ASSIGNMENT
`==` `!=` | COMPARATOR (+ NOT)
`+-*/!` | OPERATOR (ADD / SUB / MUL / DIV / NOT)
`;` | TERMINATOR
#### Reserved Keywords
These should be seen as seperate entities (`RESERVED`).
Keyword | Description
---------|------------------------------------
func | For creating functions.
return | Returns a value.
typeof | Returns the type of an expression.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment