rewrite input code for nested list tokens