Environment and identifiers
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"monkey/evaluator"
|
||||
"monkey/lexer"
|
||||
"monkey/object"
|
||||
"monkey/parser"
|
||||
)
|
||||
|
||||
@@ -13,6 +14,7 @@ const PROMPT = ">> "
|
||||
|
||||
func Start(in io.Reader, out io.Writer) {
|
||||
scanner := bufio.NewScanner(in)
|
||||
env := object.NewEnvironment()
|
||||
|
||||
for {
|
||||
fmt.Fprintf(out, PROMPT)
|
||||
@@ -31,7 +33,7 @@ func Start(in io.Reader, out io.Writer) {
|
||||
continue
|
||||
}
|
||||
|
||||
evaluated := evaluator.Eval(program)
|
||||
evaluated := evaluator.Eval(program, env)
|
||||
if evaluated != nil {
|
||||
io.WriteString(out, evaluated.Inspect())
|
||||
io.WriteString(out, "\n")
|
||||
|
||||
Reference in New Issue
Block a user