aboutsummaryrefslogtreecommitdiff
path: root/go/src/step0_repl
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-04 20:06:42 -0500
committerJoel Martin <github@martintribe.org>2014-10-04 20:06:42 -0500
commit45e1db6afbb0c63b1cd5d17e0996d7929803f37b (patch)
tree57aad492414d013e4d2b5b6eb81bc563244df02f /go/src/step0_repl
parent1ac751b20c8c6efe924737b0f88b9de6805bd5b4 (diff)
downloadmal-45e1db6afbb0c63b1cd5d17e0996d7929803f37b.tar.gz
mal-45e1db6afbb0c63b1cd5d17e0996d7929803f37b.zip
go: reading of atoms and lists.
Diffstat (limited to 'go/src/step0_repl')
-rw-r--r--go/src/step0_repl/step0_repl.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/go/src/step0_repl/step0_repl.go b/go/src/step0_repl/step0_repl.go
new file mode 100644
index 0000000..1203213
--- /dev/null
+++ b/go/src/step0_repl/step0_repl.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "strings"
+)
+
+// read
+func READ(str string) string {
+ return str
+}
+
+// eval
+func EVAL(ast string, env string) string {
+ return ast
+}
+
+// print
+func PRINT(exp string) string {
+ return exp
+}
+
+// repl
+func rep(str string) string {
+ return PRINT(EVAL(READ(str), ""))
+}
+
+func main() {
+ reader := bufio.NewReader(os.Stdin);
+ // repl loop
+ for {
+ fmt.Print("user> ");
+ text, err := reader.ReadString('\n');
+ text = strings.TrimRight(text, "\n");
+ if (err != nil) {
+ return
+ }
+ fmt.Println(rep(text))
+ }
+}