lots o fixes
Some checks failed
Build / build (push) Successful in 9m50s
Publish Image / publish (push) Failing after 49s
Test / build (push) Successful in 10m55s

This commit is contained in:
2024-04-01 18:18:45 -04:00
parent fe33fda0ab
commit 862119e90e
44 changed files with 326 additions and 170 deletions

View File

@@ -54,7 +54,7 @@ read := fn() {
}
write := fn(x) {
print(chr(x))
println(chr(x))
}
VM := fn(program) {
@@ -99,12 +99,12 @@ VM := fn(program) {
ip = ip + 1
}
print("memory:")
print(memory)
print("ip:")
print(ip)
print("dp:")
print(dp)
println("memory:")
println(memory)
println("ip:")
println(ip)
println("dp:")
println(dp)
}
// Hello World

View File

@@ -10,7 +10,7 @@ book := {
printBookName := fn(book) {
title := book["title"];
author := book["author"];
print(author + " - " + title);
println(author + " - " + title);
};
printBookName(book);

View File

@@ -4,5 +4,5 @@ fd := socket("tcp4")
bind(fd, "127.0.0.1:32535")
connect(fd, "127.0.0.1:8000")
write(fd, "Hello World")
print(read(fd))
println(read(fd))
close(fd)

15
examples/embed.go Normal file
View File

@@ -0,0 +1,15 @@
//go:build ignore
package main
import (
"log"
)
const program = `println("Hello World!")`
func main() {
if err := monkey.ExecString(program, false, false); err != nil {
log.Fatal("error running program")
}
}

View File

@@ -5,4 +5,4 @@ fact := fn(n, a) {
return fact(n - 1, a * n)
}
print(fact(5, 1))
println(fact(5, 1))

View File

@@ -11,4 +11,4 @@ if (len(args()) > 0) {
N = int(args()[0])
}
print(fib(N))
println(fib(N))

View File

@@ -21,4 +21,4 @@ if (len(args()) > 0) {
N = int(args()[0])
}
print(fib(N))
println(fib(N))

View File

@@ -14,4 +14,4 @@ if (len(args()) > 0) {
N = int(args()[0])
}
print(fib(N, 0, 1))
println(fib(N, 0, 1))

View File

@@ -14,6 +14,6 @@ test := fn(n) {
n := 1
while (n <= 100) {
print(test(n))
println(test(n))
n = n + 1
}

1
examples/hello.m Normal file
View File

@@ -0,0 +1 @@
println("Hello World!")

View File

@@ -1 +0,0 @@
print("Hello World!")

View File

@@ -1,3 +1,3 @@
name := input("What is your name? ")
print("Hello " + name)
println("Hello " + name)

View File

@@ -35,7 +35,7 @@ if (len(args()) == 1) {
n := 1
while (n < N) {
if (prime(n)) {
print(n)
println(n)
}
n = n + 1
}