I don't like this approach. Maybe use a stack to keep the state instead? I prefer not having to use switch statements since the transformers already handles calling the right methods already.