moved lexer code to lexer.py.