implement parsing types and fix parseAsRoot to do the right thing