Ejemplo n.º 1
0
func getTokens(input string) []string {
	l := lexer.New()
	go l.LexString(input)
	output := make([]string, 0)
	for {
		t := l.NextToken()
		output = append(output, t.Value)
		if t.Type == token.EOF {
			break
		}
	}
	return output
}
Ejemplo n.º 2
0
// start a new marmot instance
func New() Marmot {
	m := Marmot{
		inputs1:      make(chan string),
		inputs2:      make(chan string),
		tokens1:      make(chan token.Item),
		tokens2:      make(chan token.Item),
		trees1:       make(chan ast.Cell),
		trees2:       make(chan ast.Cell),
		outputs:      make(chan string),
		messageOut1:  make(chan string),
		messageOut2:  make(chan string),
		messageBack1: make(chan string),
		messageBack2: make(chan string),
	}
	m.lex = lexer.New(m.inputs2, m.tokens1, m.messageOut2, m.messageBack1)
	m.parse = parser.New(m.tokens2, m.trees1, m.messageOut2, m.messageBack1)
	//		m.eval = evaluator.New(trees, outputs, messageOut, messageBack)
	return m
}