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 }
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) }
func (l *lexer) emit(t tType) { l.tokens <- token{t, l.lineCount(), l.current()} l.start = l.pos l.widths = data.NewStack(10) }