master
Jordan Orelli 12 years ago
parent a3791fcc0e
commit b6a88a15fb

@ -1,8 +1,8 @@
package main
import (
"io"
"fmt"
"io"
"strings"
)

@ -88,6 +88,20 @@ func eval(v interface{}) {
fmt.Println(v)
}
func evalall(c chan token) {
for {
v, err := parse(c)
switch err {
case io.EOF:
return
case nil:
eval(v)
default:
fmt.Println("error in eval: %v", err)
}
}
}
func args() {
filename := os.Args[1]
f, err := os.Open(filename)
@ -99,18 +113,7 @@ func args() {
c := make(chan token, 32)
go lex(bufio.NewReader(f), c)
for {
v, err := parse(c)
switch err {
case io.EOF:
return
case nil:
eval(v)
default:
fmt.Println("error in args(): %v", err)
}
}
evalall(c)
}
func main() {
@ -139,17 +142,6 @@ func main() {
c := make(chan token, 32)
go lexs(string(line)+"\n", c)
for {
v, err := parse(c)
switch err {
case io.EOF:
goto OUT
case nil:
eval(v)
default:
fmt.Println("error in repl: %v", err)
}
}
OUT:
evalall(c)
}
}

Loading…
Cancel
Save