Beispiel #1
0
func main() {
	// parse flags
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %v [-src Dir] [-d NetAddress] MainCircuit Arguments...\n", os.Args[0])
		flag.PrintDefaults()
	}
	flag.Parse()
	var flagMain string
	var flagArgs = flag.Args()
	if len(flagArgs) > 0 {
		flagMain, flagArgs = flagArgs[0], flagArgs[1:]
	}
	// parse env
	if *flagSrc == "" {
		*flagSrc = os.Getenv("ESCHER")
	}

	// initialize faculties
	fos.Init(flagArgs)
	test.Init(*flagSrc)
	circuit.Init(*flagDiscover)
	//
	index := Root()
	if *flagSrc != "" {
		index.Merge(Load(*flagSrc))
	}
	// run main
	if flagMain != "" {
		verb := see.ParseVerb(flagMain)
		if Circuit(verb).IsNil() {
			fmt.Fprintf(os.Stderr, "verb not recognized\n")
			os.Exit(1)
		}
		exec(index, Circuit(verb), false)
	}
	// standard loop
	r := kio.NewChunkReader(os.Stdin)
	for {
		chunk, err := r.Read()
		if err != nil {
			fmt.Fprintf(os.Stderr, "end of session (%v)\n", err)
			if err == io.EOF || err == io.ErrUnexpectedEOF {
				break
			}
		}
		src := NewSrcString(string(chunk))
		for src.Len() > 0 {
			u := see.SeeChamber(src)
			if u == nil || u.(Circuit).Len() == 0 {
				break
			}
			fmt.Fprintf(os.Stderr, "MATERIALIZING %v\n", u)
			exec(index, u.(Circuit), true)
		}
	}
}
Beispiel #2
0
func loadCircuitFaculty(name, discover, x, y, z string) {
	acid.Init(x, y, z)
	circuit.Init(discover)
}