diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-01-14 21:10:07 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-01-15 16:57:56 +0100 |
| commit | 7ec991b8d6654aaf27a005804347346e16500a47 (patch) | |
| tree | bf36be24f2a8dffa4589aecfce75d0f0bf55f440 /tests | |
| parent | 4e6071aee97a26610aeee423d830a695b8c4d563 (diff) | |
| download | sylt-7ec991b8d6654aaf27a005804347346e16500a47.tar.gz | |
Start of typesystem
There's a type system, that kinda works
There needs to be better parsing of types, since not all types are
currently parsable. Some of them are, and the simple stuff works!
:D
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fun.tdy | 16 | ||||
| -rw-r--r-- | tests/simple.tdy | 44 |
2 files changed, 24 insertions, 36 deletions
diff --git a/tests/fun.tdy b/tests/fun.tdy index 8b94cad..8dc3b77 100644 --- a/tests/fun.tdy +++ b/tests/fun.tdy @@ -2,13 +2,13 @@ f := fn { print 1 } -f() <=> true +f() // Simple f2 := fn a: int { print a } -f2(2) <=> true +f2(2) // Return value f3 := fn -> int { @@ -39,3 +39,15 @@ g := fn f: int { } g(h) <=> 1 + + +q := fn i: int -> int { + if i == 1 { + ret 2 + } else { + ret 3 + } +} + +q(1) <=> 2 +q(0) <=> 3 diff --git a/tests/simple.tdy b/tests/simple.tdy index 2f0f606..6dde932 100644 --- a/tests/simple.tdy +++ b/tests/simple.tdy @@ -1,38 +1,14 @@ -// 1 + 1 <=> 2 -// // asdlkjasl -// print 1 + 3 -// // OwO - -// a int := 0 -// b int := 1 -// c int := 3 -// d int := 2 +// a := 1 +// a = 2 + 1 +// a = 3 // -// print a -// print b -// print d -// print c +// for i := 0, i < 10, i = i + 1 { +// print i + 1 +// print i + 2 +// } -for a := 0, a < 10, print a { - print a - a = a + 1 +f := fn b: int -> int { + ret b + 1 } -// 1, 2, 3, 4 - - -// -// === main === -// | Constant(Int(0)) -// | ReadLocal(0) -// | Constant(Int(10)) -// | Less -// | JmpFalse(12) -// | Jmp(11) -// | Jmp(1) -// | ReadLocal(0) -// | Constant(Int(1)) -// | Add -// | Assign(0) -// | Jmp(7) -// | Return +f(1) |
