Пример #1
0
func (h *see) CognizeSource(v interface{}) {
	src, ok := basic.AsString(v)
	if !ok {
		panic("non-string name perceived by os.see")
	}
	h.seen.ReCognize(es.MaterializeCircuit(es.NewSrcString(src)))
}
Пример #2
0
func TestUnderstand(t *testing.T) {
	//fmt.Printf(src)
	for _, r := range src {
		s := see.SeeCircuit(see.NewSrcString(r))
		t := Understand(s)
		printf2(t.Print("", "\t"))
	}
}
Пример #3
0
func (See) Materialize() be.Reflex {
	reflex, _ := plumb.NewEyeCognizer(
		func(eye *plumb.Eye, dvalve string, dvalue interface{}) {
			if dvalve != "Source" {
				return
			}
			eye.Show("Seen", es.SeeCircuit(es.NewSrcString(plumb.AsString(dvalue))))
		},
		"Source", "Seen",
	)
	return reflex
}
Пример #4
0
func (fty Faculty) UnderstandFile(file string) {
	text, err := ioutil.ReadFile(file)
	if err != nil {
		println(file)
		panic(err)
	}
	src := see.NewSrcString(string(text))
	for {
		s := see.SeeCircuit(src)
		if s == nil {
			break
		}
		fty.interpretCircuit(Understand(s))
	}
}
Пример #5
0
// LoadFile ...
func (fty Faculty) LoadFile(dir, filePath string) {
	text, err := ioutil.ReadFile(filePath)
	if err != nil {
		log.Fatalf("Problem reading source file %s (%v)", filePath, err)
	}
	src := see.NewSrcString(string(text))
	for {
		n_, u_ := see.SeePeer(src)
		if n_ == nil {
			break
		}
		n := n_.(string) // n is a string
		u := u_.(Circuit)
		u.Include(Genus_{},
			&CircuitGenus{
				Dir:  dir,
				File: filePath,
			},
		)
		if _, ok := fty.Include(n, u); ok {
			log.Fatalf("file circuit overwrites %s", n)
		}
	}
}