Pure python lexer implementation. It's somewhat designed to be a drop-in replacement for PLY's lexer for use with yacc.