From 69fc902f8f5fd8f36db0991f6ba4faeabb3090fa Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 20 May 2017 16:27:42 +0200 Subject: 03 --- repl/repl.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'repl') 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") + } } } -- cgit v1.2.3