From 45e1db6afbb0c63b1cd5d17e0996d7929803f37b Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sat, 4 Oct 2014 20:06:42 -0500 Subject: go: reading of atoms and lists. --- go/src/step0_repl/step0_repl.go | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 go/src/step0_repl/step0_repl.go (limited to 'go/src/step0_repl') 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)) + } +} -- cgit v1.2.3