Restructure lex/parse functions