mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-16 18:35:02 +01:00
semicolons are needed lol
This commit is contained in:
parent
186eb71a50
commit
ea4282747d
1 changed files with 30 additions and 30 deletions
60
README.md
60
README.md
|
|
@ -1,6 +1,6 @@
|
||||||
_ is a small embeddable scripting language
|
language_name is a small embeddable scripting language
|
||||||
|
|
||||||
_ is inspired by Javascript, Lox, Lua, Python, Rust and more
|
language_name is inspired by Javascript, Lox, Lua, Python, Rust and more
|
||||||
|
|
||||||
# Reference
|
# Reference
|
||||||
|
|
||||||
|
|
@ -9,47 +9,47 @@ _ is inspired by Javascript, Lox, Lua, Python, Rust and more
|
||||||
Declaring variables using `let`
|
Declaring variables using `let`
|
||||||
|
|
||||||
```
|
```
|
||||||
let hello = 4
|
let hello = 4;
|
||||||
```
|
```
|
||||||
|
|
||||||
Semicolons are not needed
|
Semicolons are needed :)
|
||||||
|
|
||||||
```
|
```
|
||||||
let test = 5
|
let test = 5;
|
||||||
let another = 4
|
let another = 4;
|
||||||
```
|
```
|
||||||
|
|
||||||
The language has strings, numbers, arrays, objects and null and booleans
|
The language has strings, numbers, arrays, objects and null and booleans
|
||||||
|
|
||||||
```
|
```
|
||||||
let string = "hallo"
|
let string = "hallo";
|
||||||
let number = 4
|
let number = 4;
|
||||||
let array = []
|
let array = [];
|
||||||
let object = {}
|
let object = {};
|
||||||
let _null = null
|
let _null = null;
|
||||||
let bool = true
|
let bool = true;
|
||||||
```
|
```
|
||||||
|
|
||||||
You access properties on objects using `.`
|
You access properties on objects using `.`
|
||||||
|
|
||||||
```
|
```
|
||||||
let obj = {}
|
let obj = {};
|
||||||
obj.hi = "hi!"
|
obj.hi = "hi!";
|
||||||
```
|
```
|
||||||
|
|
||||||
Functions are first class
|
Functions are first class
|
||||||
|
|
||||||
```
|
```
|
||||||
let obj = {}
|
let obj = {};
|
||||||
obj.hello = helloFn
|
obj.hello = helloFn;
|
||||||
obj.hello()
|
obj.hello();
|
||||||
```
|
```
|
||||||
|
|
||||||
Functions are declared using `fn`
|
Functions are declared using `fn`
|
||||||
|
|
||||||
```
|
```
|
||||||
fn greet(name) {
|
fn greet(name) {
|
||||||
return "hello, " + name
|
return "hello, " + name;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -70,15 +70,15 @@ There are many native functions, that can easily be customized and added/removed
|
||||||
|
|
||||||
```
|
```
|
||||||
# rocket game
|
# rocket game
|
||||||
turnRocketLeft(29)
|
turnRocketLeft(29);
|
||||||
turnRocketRight(32)
|
turnRocketRight(32);
|
||||||
|
|
||||||
# chat bot
|
# chat bot
|
||||||
message.respond("hi")
|
message.respond("hi");
|
||||||
|
|
||||||
# dangerous http requests
|
# dangerous http requests
|
||||||
fn callback(html) {
|
fn callback(html) {
|
||||||
print(html)
|
print(html);
|
||||||
}
|
}
|
||||||
fetch("https://github.com/Nilstrieb", callback);
|
fetch("https://github.com/Nilstrieb", callback);
|
||||||
```
|
```
|
||||||
|
|
@ -86,10 +86,10 @@ fetch("https://github.com/Nilstrieb", callback);
|
||||||
Basic arithmetic and boolean logic is available
|
Basic arithmetic and boolean logic is available
|
||||||
|
|
||||||
```
|
```
|
||||||
let a = 5
|
let a = 5;
|
||||||
let b = 5
|
let b = 5;
|
||||||
print(a + b / b * b - a % b)
|
print(a + b / b * b - a % b);
|
||||||
print(true and false or false or true and false)
|
print(true and false or false or true and false);
|
||||||
```
|
```
|
||||||
|
|
||||||
Loops and conditionals
|
Loops and conditionals
|
||||||
|
|
@ -97,15 +97,15 @@ Loops and conditionals
|
||||||
```
|
```
|
||||||
let x = true
|
let x = true
|
||||||
if x {
|
if x {
|
||||||
print("true!")
|
print("true!");
|
||||||
} else {
|
} else {
|
||||||
print("false :(")
|
print("false :(");
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
while 1 > 5 {
|
while 1 > 5 {
|
||||||
print("yeet")
|
print("yeet");
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
# no for loops for now, but will be added (probably like python)
|
# no for loops for now, but will be added (probably like python)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue