Modularize and improve get_next_lexeme