Example #1
0
func Lex(input string) *Lexer {
	l := &Lexer{
		input:        input,
		state:        lexIndent,
		indentLevels: data.NewStack(10),
		widths:       data.NewStack(10),
		tokens:       make(chan token.Token, 10),
	}
	l.indentLevels.Push(0)
	go l.run()
	return l
}
Example #2
0
func (l *Lexer) emit(t token.Type) {
	l.tokens <- token.Token{t, token.Position{l.lineCount(), l.charCount()}, l.current()}
	l.start = l.pos
	l.widths = data.NewStack(10)
}
Example #3
0
func (l *lexer) emit(t tType) {
	l.tokens <- token{t, l.lineCount(), l.current()}
	l.start = l.pos
	l.widths = data.NewStack(10)
}