diff --git a/README.md b/README.md index 5cd743e..f088ad2 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Monkey is an interpreted language written in Go. *This project is still under de + [ ] feat: scroll in command history with up and down keys + [ ] feat: PrettyPrint, color, AST, etc + [ ] feat: sys call such as print(...) ++ [ ] feat: add a helper for available functions ## References diff --git a/internal/repl/repl.go b/internal/repl/repl.go index 34fb9b4..32b44fd 100644 --- a/internal/repl/repl.go +++ b/internal/repl/repl.go @@ -43,8 +43,8 @@ func (r *repl) Start(in io.ReadCloser, out io.WriteCloser, userName string) { l := lexer.New() p := parser.New(l) - io.WriteString(out, MONKEY_FACE) - io.WriteString(out, fmt.Sprintf("Hello %s! This is the Monkey programming language!\n", userName)) + fmt.Print(MONKEY_FACE) + fmt.Printf("Hello %s! This is the Monkey programming language!\n", userName) for { fmt.Print(PROMPT) @@ -61,15 +61,15 @@ func (r *repl) Start(in io.ReadCloser, out io.WriteCloser, userName string) { printParserErrors(out, errs) } - io.WriteString(out, program.String()) - io.WriteString(out, "\n") + // TODO: PrettyPrint + fmt.Println(program.String()) } } func printParserErrors(out io.WriteCloser, errs []error) { - io.WriteString(out, "parser errors:\n") + fmt.Println("parser errors:") for _, err := range errs { - io.WriteString(out, "\t"+err.Error()+"\n") + fmt.Println("\t" + err.Error()) } } diff --git a/internal/repl/repl_test.go b/internal/repl/repl_test.go index f28a19f..3d0d754 100644 --- a/internal/repl/repl_test.go +++ b/internal/repl/repl_test.go @@ -1,10 +1,14 @@ package repl_test import ( + "github.com/aden-q/monkey/internal/repl" . "github.com/onsi/ginkgo/v2" - _ "github.com/onsi/gomega" + . "github.com/onsi/gomega" ) var _ = Describe("Repl", func() { - + It("New", func() { + r := repl.New(repl.Config{}) + Expect(r).ToNot(BeNil()) + }) })