-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fixing ast/parsing issues with structs and struct access - fixing modulus operator lexing issue - updating playground - adding deploy to gh-pages for playground - update readme
- Loading branch information
1 parent
b3e02cf
commit 3b69dbe
Showing
38 changed files
with
1,889 additions
and
354 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tools/ast_explorer/static/main.wasm | ||
tools/ast_explorer/static/wasm_exec.js | ||
|
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,9 @@ | ||
punch: | ||
go build ./cmd/punch/ | ||
|
||
run-ast-explorer: | ||
bash ./scripts/build_wasm.sh | ||
go run ./tools/ast_explorer/ | ||
|
||
clean: | ||
rm punch |
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
pkg main | ||
|
||
bool is_eq(i32 a, i32 b) { | ||
return a == b | ||
} | ||
|
||
i32 add_two(i32 x, i32 y, i32 z) { | ||
println("x =", x, "y =", y, "z =", z) | ||
println("Hello, World!") | ||
println("some other string") | ||
return x + y | ||
} | ||
|
||
i32 add_four(i32 a, i32 b, i32 c, i32 d) { | ||
return a + b + c + d | ||
} | ||
|
||
pub fn hello(bool is_hello) { | ||
if is_hello { | ||
println("hello, again") | ||
} | ||
if is_eq(2, 2) { | ||
println("2 is equal") | ||
} | ||
|
||
println("adding some nums:", add_two(4,5,2)) | ||
} | ||
|
||
|
||
hello(true) |
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,11 @@ | ||
pkg main | ||
|
||
i32 factorial(i32 n) { | ||
i32 result = 1 | ||
for i32 i = 1; i <= n; i = i + 1 { | ||
result = result * i | ||
} | ||
return result | ||
} | ||
|
||
println("Factorial of 5 is {}", factorial(5)); |
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,13 @@ | ||
pkg main | ||
|
||
i32 fibonacci(i32 n) { | ||
if n == 0 { | ||
return 0 | ||
} | ||
if n == 1 { | ||
return 1 | ||
} | ||
return fibonacci(n - 1) + fibonacci(n - 2) | ||
} | ||
|
||
println("Fibonacci(10) is {}", fibonacci(10)) |
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,7 @@ | ||
pkg main | ||
|
||
pub fn greet(str name) { | ||
println("Hello,", name) | ||
} | ||
|
||
greet("World!") |
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,11 @@ | ||
pkg main | ||
|
||
pub fn check_number(i32 x) { | ||
if x > 0 { | ||
println(x, "is positive") | ||
} | ||
} | ||
|
||
check_number(5) | ||
|
||
check_number(-3) |
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,9 @@ | ||
pkg main | ||
|
||
pub fn count_to(i32 n) { | ||
for i32 i = 1; i <= n; i = i + 1 { | ||
println(i) | ||
} | ||
} | ||
|
||
count_to(5) |
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,13 @@ | ||
pkg main | ||
|
||
pub fn math_operations() { | ||
i32 a = 10 | ||
i32 b = 20 | ||
println("Addition: ", a + b) | ||
println("Subtraction: ", a - b) | ||
println("Multiplication: ", a * b) | ||
println("Division: ", b / a) | ||
println("Modulus: ", b % a) | ||
} | ||
|
||
math_operations() |
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,13 @@ | ||
pkg main | ||
|
||
i32 fibonacci(i32 n) { | ||
if n == 0 { | ||
return 0 | ||
} | ||
if n == 1 { | ||
return 1 | ||
} | ||
return fibonacci(n - 1) + fibonacci(n - 2) | ||
} | ||
|
||
println("Fibonacci(10) is {}", fibonacci(10)) |
Oops, something went wrong.