You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
684 B
Go
43 lines
684 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
var tcpAddr = flag.String("tcp", "", "foo")
|
|
|
|
func args() {
|
|
flag.Parse()
|
|
if *tcpAddr != "" {
|
|
runTCPServer()
|
|
return
|
|
}
|
|
filename := flag.Args()[1]
|
|
f, err := os.Open(filename)
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, "unable to read file ", filename)
|
|
os.Exit(1)
|
|
}
|
|
defer f.Close()
|
|
|
|
out, errors := make(chan interface{}), make(chan error)
|
|
go defaultInterpreter(out, errors)
|
|
|
|
c := make(chan token, 32)
|
|
go lex(bufio.NewReader(f), c)
|
|
evalall(c, out, errors, universe)
|
|
}
|
|
|
|
func printErrorMsg(message string) {
|
|
io.WriteString(os.Stderr, message)
|
|
}
|
|
|
|
func die(message string) {
|
|
printErrorMsg(message)
|
|
os.Exit(2)
|
|
}
|