aboutsummaryrefslogtreecommitdiff
path: root/repl/repl.go
diff options
context:
space:
mode:
Diffstat (limited to 'repl/repl.go')
-rw-r--r--repl/repl.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/repl/repl.go b/repl/repl.go
index 3d75f8a..e267e1d 100644
--- a/repl/repl.go
+++ b/repl/repl.go
@@ -16,6 +16,7 @@ const PROMPT = ">> "
func Start(in io.Reader, out io.Writer) {
scanner := bufio.NewScanner(in)
env := object.NewEnvironment()
+ macroEnv := object.NewEnvironment()
for {
fmt.Print(PROMPT)
@@ -34,7 +35,10 @@ func Start(in io.Reader, out io.Writer) {
continue
}
- evaluated := evaluator.Eval(program, env)
+ evaluator.DefineMacros(program, macroEnv)
+ expanded := evaluator.ExpandMacros(program, macroEnv)
+
+ evaluated := evaluator.Eval(expanded, env)
if evaluated != nil {
io.WriteString(out, evaluated.Inspect())
io.WriteString(out, "\n")