gagent/pkg/picol/picol_unused/main.go_unused
James Wells 1bcc682b7c
refactor: converted int64 to int32 where appropriate.
refactor: reduced usage of fmt in favor of logs and string concatication.

refactor: minor re-ordering of the data structures to reduce storage space required.
2023-03-21 07:34:10 -07:00

37 lines
670 B
Text

package main
import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"os"
picol "github.com/dragonheim/gagent/pkg/picol"
)
var fname = flag.String("f", "", "file name")
func main() {
flag.Parse()
interp := picol.NewInterpreter()
interp.RegisterCoreCommands()
buf, err := ioutil.ReadFile(*fname)
if err == nil {
result, err := interp.Eval(string(buf))
if err != nil {
fmt.Println("ERRROR", result, err)
}
} else {
for {
fmt.Print("picol> ")
scanner := bufio.NewReader(os.Stdin)
clibuf, _ := scanner.ReadString('\n')
result, err := interp.Eval(clibuf[:len(clibuf)-1])
if len(result) != 0 {
fmt.Println("ERRROR", result, err)
}
}
}
}