Skip to content

Commit

Permalink
simple upgrade to readlines library
Browse files Browse the repository at this point in the history
  • Loading branch information
CrowdHailer committed Aug 30, 2023
1 parent 44610fe commit 1613d2c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
27 changes: 19 additions & 8 deletions mulch/cmd/repl/repl.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import (
"bufio"
"fmt"
"mulch"
"mulch/lisp"
"os"

"github.com/chzyer/readline"
)

// Need persistent datastructures for env
Expand All @@ -16,15 +16,26 @@ func main() {

func repl() {
fmt.Println("read")
in := bufio.NewReader(os.Stdin)
input := ""
// in := bufio.NewReader(os.Stdin)
// input := ""
rl, err := readline.New("> ")
if err != nil {
panic(err)
}
defer rl.Close()

// var e E = emptyEnv()
for input != "." {
input, err := in.ReadString('\n')
if err != nil {
panic(err)
// for input != "." {

for {
input, err := rl.Readline()
if err != nil { // io.EOF
break
}
// input, err := in.ReadString('\n')
// if err != nil {
// panic(err)
// }
source, err := lisp.Parse(input)
if err != nil {
fmt.Printf("failed to parse input: %s", err.Error())
Expand Down
2 changes: 2 additions & 0 deletions mulch/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ go 1.20
require github.com/tj/assert v0.0.3

require (
github.com/chzyer/readline v1.5.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/sys v0.11.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect
)
7 changes: 7 additions & 0 deletions mulch/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -12,6 +16,9 @@ github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down

0 comments on commit 1613d2c

Please sign in to comment.