Switch from a flat representation to a nested parse tree