aboutsummaryrefslogtreecommitdiff
path: root/repl
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-05-20 16:27:42 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-05-20 16:27:42 +0200
commit69fc902f8f5fd8f36db0991f6ba4faeabb3090fa (patch)
tree36b77847cb8548047f3c8bc7a9d40ae017b86658 /repl
parentce78935009d931faf2db7e882929a7a4c95ce3e0 (diff)
03
Diffstat (limited to 'repl')
-rw-r--r--repl/repl.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/repl/repl.go b/repl/repl.go
index 7fa3e42..7097e68 100644
--- a/repl/repl.go
+++ b/repl/repl.go
@@ -4,7 +4,9 @@ import (
"bufio"
"fmt"
"io"
+ "monkey/evaluator"
"monkey/lexer"
+ "monkey/object"
"monkey/parser"
)
@@ -12,6 +14,7 @@ const PROMPT = ">> "
func Start(in io.Reader, out io.Writer) {
scanner := bufio.NewScanner(in)
+ env := object.NewEnvironment()
for {
fmt.Printf(PROMPT)
@@ -30,8 +33,11 @@ func Start(in io.Reader, out io.Writer) {
continue
}
- io.WriteString(out, program.String())
- io.WriteString(out, "\n")
+ evaluated := evaluator.Eval(program, env)
+ if evaluated != nil {
+ io.WriteString(out, evaluated.Inspect())
+ io.WriteString(out, "\n")
+ }
}
}