Refactor parser

Each state is now a nested fuction on the Parser. Embracing functions.