func (l *Lexer) Lex(yylval *migoSymType) int {
	token := l.scanner.Scan()
	switch token := token.(type) {
	case *DigitsToken:
		yylval.num = token.num
	case *IdentToken:
		yylval.str = token.str
	}
	return int(token.Tok())
}
Lex is provided for yacc-compatible parser.
package parser
import "io"
type Lexer struct {
	scanner *Scanner
	Errors  chan error
}
func NewLexer(r io.Reader) *Lexer {
	return &Lexer{scanner: NewScanner(r), Errors: make(chan error, 1)}
}