This commit is contained in:
able 2023-09-07 08:56:15 -05:00
parent 01cdcf249e
commit cd4d419c96
8 changed files with 86 additions and 10 deletions

View file

@ -0,0 +1,13 @@
func main(){
var i = 0;
loop {
match i {
10 -> break;
}
i = i + 1;
}
loop {}
}

View file

@ -0,0 +1,9 @@
var std = import "std";
var print = std.print;
func main() {
match 2 {
1 -> { print("One") }
2 -> { print("Two") }
}
}

View file

@ -3,4 +3,7 @@
const C = 299_792_458; const C = 299_792_458;
const pi = 3.141592653589793; const pi = 3.141592653589793;
const π = pi;
const tau = 6.283185307179586; const tau = 6.283185307179586;
const 𝜏 = tau;

View file

@ -1 +1,24 @@
var constants = include "constants"; var constants = include "constants";
func square_root(value){
match value{
0..1 -> return value;
value -> {
var y = x;
var z = (y + (x/y)) / 2;
// NOTE: not finalized syntax
while abs(y - z) >= 0.00001{
y = z
z = (y + (x/y)) / 2
}
return z;
}
}
}
var sqrt = square_root;
var √ = square_root;
func absolute_value(value){
}
var abs = absolute_value;

View file

@ -1 +1,6 @@
var log = include "log"; var log = include "log";
func print(value) {
// TODO: define an api for output
}

View file

@ -1,5 +1,25 @@
func error(){} var io = include "io";
func warn(){} var print = io.print;
func info(){}
func debug(){} // TODO: include time in the log
func trace(){}
func error(value){
print("error " + value)
}
func warn(value){
print("warn " + value)
}
func info(value){
print("info " + value)
}
func debug(value){
print("debug " + value)
}
func trace(value){
print("trace " + value)
}

View file

@ -1,2 +1,4 @@
var io = include "std.io"; var io = include "io";
var math = include "math" var math = include "math";
var print = io.print;

View file

@ -58,6 +58,7 @@ pub enum Token {
#[token("const")] Const, #[token("const")] Const,
#[token("var")] Var, #[token("var")] Var,
#[token("func")] Func, #[token("func")] Func,
// Modules aren't real here ondra just variables with imported functions
#[token("module")] Module, #[token("module")] Module,
#[regex( #[regex(