Beispiel #1
0
// New is the factory for Typechecker visitor struct
func New() (ast.Executer, *symboltable.SymbolTable) {
	toFrontend := make(chan *plumbing.Frontend)
	st := symboltable.New()

	go fakeFrontendDriver(toFrontend)

	tc := &Typechecker{
		execute: execute.New(toFrontend, st),
	}
	return tc, st
}
Beispiel #2
0
// New starts interpreter with an AST (*ast.Questionaire) and with
// channels to communicate with Frontend process.
func New(q *ast.QuestionaireNode) *plumbing.Pipes {
	typecheck(q)

	pipes := plumbing.New()
	st := symboltable.New()

	v := &interpreter{
		questionaire: q,
		send:         pipes.ToFrontend(),
		receive:      pipes.FromFrontend(),
		execute:      execute.New(pipes.ToFrontend(), st),
		draw:         draw.New(pipes.ToFrontend()),
		symbols:      st,
	}
	go v.loop()

	return pipes
}