func (l *Lexer) next() rune {
	var r rune
	if l.pos >= len(l.input) {
		l.width = 0
		return eof
	}
	r, l.width = utf8.DecodeRuneInString(l.input[l.pos:])
	l.pos += l.width
	l.prevColumn = l.column
	if r == '\n' {
		l.line++
		l.column = 0
	} else {
		l.column++
	}
	return r
}
next consumes the next rune from input
package scanner
import (
	"fmt"
	"strings"
	"unicode"
	"unicode/utf8"
	"github.com/madlambda/nash/token"
)
type (
	Token struct {
		typ token.Token
		token.FileInfo
		val string
	}
	stateFn func(*Lexer) stateFn
	Lexer struct {
		name  string  
		input string  
		start int     
		width  int         
		Tokens chan Token  
		pos         int  
		line        int  
		lineStart   int  
		prevColumn  int  
		column      int  
		columnStart int  
		openParens int
		addSemicolon bool
	}
)
const (
	eof = -1
)
func (i Token) Type() token.Token { return i.typ }
func (i Token) Value() string     { return i.val }
func (i Token) String() string {
	switch i.typ {
	case token.Illegal:
		return "ERROR: " + i.val
	case token.EOF:
		return "EOF"
	}
	if len(i.typ.String()) > 10 {
		return fmt.Sprintf("%s...", i.typ.String()[0:10])
	}
	return fmt.Sprintf("%s", i.typ)
}
func (l *Lexer) run() {
	l.line, l.lineStart, l.column, l.columnStart = 1, 1, 0, 0
	for state := lexStart; state != nil; {
		state = state(l)
	}
	l.emit(token.EOF)
	close(l.Tokens)  
}
func (l *Lexer) emitVal(t token.Token, val string, line, column int) {
	l.Tokens <- Token{
		FileInfo: token.NewFileInfo(line, column),
		typ: t,
		val: val,
	}
	l.start = l.pos
	l.lineStart = l.line
	l.columnStart = l.column
}
func (l *Lexer) emit(t token.Token) {
	l.Tokens <- Token{
		FileInfo: token.NewFileInfo(l.lineStart, l.columnStart),
		typ: t,
		val: l.input[l.start:l.pos],
	}
	l.start = l.pos
	l.lineStart = l.line
	l.columnStart = l.column
}
func (l *Lexer) peek() rune {
	rune := l.next()
	l.backup()
	return rune
}