Skip to content

Commit

Permalink
Merge pull request #27 from JunNishimura/feature/update_repl
Browse files Browse the repository at this point in the history
udpate repl
  • Loading branch information
JunNishimura authored Jul 15, 2024
2 parents 629581b + 69ef1c1 commit 44ccf0a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion repl/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Printf("%s", PROMPT)
Expand All @@ -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")
Expand Down

0 comments on commit 44ccf0a

Please sign in to comment.