credit to udacity for lexer code