1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00

remove semicolons part 2

This commit is contained in:
Natapat Samutpong 2022-04-03 15:07:25 +07:00
parent 6b984f8711
commit 6d41cc4ded
12 changed files with 54 additions and 81 deletions

View file

@ -1,14 +0,0 @@
fun add2 (lhs: int) (rhs: int): int = do
return lhs + rhs
end
fun main: void = do
let result: int = add2(34, 35)
@write(result)
@write("\n")
if result == 69 then
@write("big cool")
else
@write("not cool")
end
end

View file

@ -1,3 +1,3 @@
let foo: int = "123"; let foo: int = "123"
let bar: string = 69; let bar: string = 69
let baz: bool = "true"; let baz: bool = "true"

View file

@ -1,7 +1,7 @@
fun main: void = do fun main: void = do
do do
let foo: string = "Hello"; let foo: string = "Hello"
@write(foo); @write(foo)
end; end
@write(foo); -- TODO: This is a runtime error @write(foo) -- TODO: This is a runtime error
end; end

View file

@ -1,12 +0,0 @@
fun main: void = do
let foo: int = 69;
match foo with
| 1 -> @write("One");
| 2 -> @write("Two");
| 3 -> do
@write("Three");
end;
-- \ @write("idk");
end;
end;

View file

@ -1,3 +1,3 @@
fun main: void = do fun main: void = do
@throw("woopsie"); @throw("woopsie")
end; end

View file

@ -1,3 +1,3 @@
fun main: void = do fun main: void = do
@writse(); -- Unknown intrinsic @writse() -- Unknown intrinsic
end; end

View file

@ -1,4 +1,3 @@
pub fun print_something: void = @emit("console.log('something')"); pub fun print_something: void = @emit("console.log('something')")
fun main: void = do fun main: void = do end
end;

View file

@ -1,11 +1,11 @@
fun fib (n: int): int = do fun fib (n: int): int = do
if n < 2 then if n < 2 then
return n; return n
else else
return fib(n - 1) + fib(n - 2); return fib(n - 1) + fib(n - 2)
end; end
end; end
fun main: void = do fun main: void = do
fib(5) |> @write(_); fib(5) |> @write(_)
end; end

View file

@ -1,15 +1,15 @@
fun main: void = do fun main: void = do
if true then if true then
@write("True"); @write("True")
else else
@write("False"); @write("False")
end; end
if true then if true then
do do
@write("True"); @write("True")
end; end
else else
@write("False"); @write("False")
end; end
end; end

View file

@ -1,23 +1,23 @@
fun iter_ (vec: vec_int) (current: int): void = do fun iter_ (vec: vec_int) (current: int): void = do
if current == @len(vec) then if current == @len(vec) then
do end; do end
else else
do do
-- iter logic -- iter logic
-- TODO: function as argument -- TODO: function as argument
@get(vec current) |> @write(_); @get(vec, current) |> @write(_)
@write("\n"); @write("\n")
iter_(vec, current + 1); iter_(vec, current + 1)
end; end
end; end
end; end
fun iter (vec: vec_int): void = do fun iter (vec: vec_int): void = do
iter_(vec, 0); iter_(vec, 0)
end; end
fun main: void = do fun main: void = do
let foo: vec_int = [69, 420, 727, 1337, 42069, 69420]; let foo: vec_int = [69, 420, 727, 1337, 42069, 69420]
iter(foo); iter(foo)
end; end

View file

@ -1,14 +1,14 @@
fun foo (xs: int): int = return xs + 1; fun foo (xs: int): int = return xs + 1
fun bar (xs: int) (x: int): int = return xs - x; fun bar (xs: int) (x: int): int = return xs - x
fun main: void = do fun main: void = do
foo(69) -- 69 + 1 => 70 foo(69) -- 69 + 1 => 70
|> bar(_, 1) -- '70 - 1 => 69 |> bar(_, 1) -- '70 - 1 => 69
|> @write(_); -- '69 => stdout |> @write(_) -- '69 => stdout
@write("\n"); @write("\n")
foo(60) -- 60 + 1 => 61 foo(60) -- 60 + 1 => 61
|> bar(130, _) -- 130 - '61 => 69 |> bar(130, _) -- 130 - '61 => 69
|> @write(_); -- '69 => stdout |> @write(_) -- '69 => stdout
end; end

View file

@ -1,8 +1,8 @@
fun foo (xs: int) : int = return xs + 1; fun foo (xs: int) : int = return xs + 1
fun bar (xs: int) (ys: int) : int = return xs + ys; fun bar (xs: int) (ys: int) : int = return xs + ys
fun baz (xs: int) (ys: int) (zs: int): int = return xs + ys + zs; fun baz (xs: int) (ys: int) (zs: int): int = return xs + ys + zs
fun qux (xs: int) : int = return xs - 1; fun qux (xs: int) : int = return xs - 1
fun quux (xs: int) (xy: int) : int = return xs - 2 + xy; fun quux (xs: int) (xy: int) : int = return xs - 2 + xy
fun main: void = do fun main: void = do
66 66
@ -11,9 +11,9 @@ fun main: void = do
|> baz(1, 2, _) |> baz(1, 2, _)
|> qux(_) |> qux(_)
|> quux(1, _) |> quux(1, _)
|> @write(_); |> @write(_)
210 210
|> bar(_, _) |> bar(_, _)
|> @write(_); |> @write(_)
end; end