diff options
Diffstat (limited to 'go/src/step0_repl')
| -rw-r--r-- | go/src/step0_repl/step0_repl.go | 42 |
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)) + } +} |
