-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(git): merged pull request #28 from plume-lang/feat/javascript-b…
…ackend Feat/javascript backend
- Loading branch information
Showing
110 changed files
with
11,670 additions
and
3,589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,8 @@ compile_commands.json | |
|
||
*.plmc | ||
|
||
CMakeFiles | ||
CMakeFiles | ||
|
||
node_modules | ||
|
||
example/*.js |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,34 @@ | ||
fn facto (n: int): int => | ||
switch n { | ||
case 0 => 1 | ||
case ? => n * facto(n - 1) | ||
} | ||
interface<Env, A, Ret> Closure1<Env, A, Ret> { | ||
fn apply1(env: Env, a: A): Ret | ||
} | ||
|
||
@println(facto(5)) | ||
interface<Env, A, B, Ret> Closure2<Env, A, B, Ret> { | ||
fn apply2(env: Env, a: A, b: B): Ret | ||
} | ||
|
||
interface<Env, A, B, C, Ret> Closure3<Env, A, B, C, Ret> { | ||
fn apply3(env: Env, a: A, b: B, c: C): Ret | ||
} | ||
|
||
interface<Env, A, B, C, D, Ret> Closure4<Env, A, B, C, D, Ret> { | ||
fn apply4(env: Env, a: A, b: B, c: C, d: D): Ret | ||
} | ||
|
||
fn add(x: int) => fn(y: int) => x + y | ||
|
||
// Would be converted to | ||
|
||
type add_closure = int | ||
|
||
extend Closure1<add_closure, int, int> { | ||
fn apply1(env: add_closure, y: int): int => env + y | ||
} | ||
|
||
extend Closure1<unit, int, add_closure> { | ||
fn apply1(_: unit, x: int): add_closure => x | ||
} | ||
|
||
x: add_closure = apply1(unit, 42) | ||
y: int = apply1(x, 42) | ||
|
||
println(y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
@println(3 ^ 3) | ||
println(3 ^ 3) | ||
|
||
println([1, 2, 3, 4, 5].show()) | ||
println([1, 2, 3, 4, 5]) | ||
|
||
@println("Hello, World!") | ||
println("Hello, World!") | ||
|
||
@println(Some(8)) | ||
|
||
extend str { | ||
fn test(): str => "tesdt" | ||
} | ||
println(Some(8)) | ||
|
||
fn bruh(n: str) { | ||
[n, n, n, n].map(println) | ||
[n, n, n, n].map(fn(x) => println(x)) | ||
|
||
return n | ||
} | ||
|
||
@println(bruh("test")) | ||
println(bruh("test")) | ||
|
||
println("Hello" + "World") | ||
|
||
println([1, 2, 3] == [4, 5, 6]) | ||
println([1, 2, 3] == [1, 2, 3]) | ||
println([1, 2, 3] != [4, 5, 6]) | ||
println([1, 2, 3] != [1, 2, 3]) | ||
|
||
@println("Hello" + "World") | ||
println([1, 2, 3] + [4, 5, 6]) | ||
|
||
@println([1, 2, 3] == [4, 5, 6]) | ||
@println([1, 2, 3] == [1, 2, 3]) | ||
@println([1, 2, 3] != [4, 5, 6]) | ||
@println([1, 2, 3] != [1, 2, 3]) | ||
fn test(x: str) => fn(_: int): str { | ||
return switch x { | ||
case "a" => "b" | ||
case ? { | ||
if true { | ||
return "c" | ||
} else { | ||
return "d" | ||
} | ||
} | ||
} | ||
} | ||
|
||
@println([1, 2, 3] + [4, 5, 6]) | ||
x = test("a")(9) | ||
println(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
fn facto (n: int): int => | ||
switch n { | ||
case 0 => 1 | ||
case ? { | ||
f = facto(n - 1) | ||
return n * f | ||
} | ||
} | ||
|
||
|
||
fn range(from: int, to: int): [int] { | ||
if from == to { | ||
return [] | ||
} else { | ||
return [from] + range(from + 1, to) | ||
} | ||
} | ||
|
||
xs = range(0, 21).map(fn(n) => (n, facto(n))) | ||
|
||
xs.map(fn case (n, f) => println("$n! = $f")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fn fib(n: int): int => | ||
switch n { | ||
case 0 => 0 | ||
case 1 => 1 | ||
case ? => fib(n - 1) + fib(n - 2) | ||
} | ||
|
||
println(fib(30)) |
Oops, something went wrong.