XD-956: Parser refactoring

See https://jira.springsource.org/browse/XD-956

This replaces the previous pull request. I addressed all the comments on the previous request. I also added a test for XD-299 which seems to no longer be a problem due to the parser refactoring here.  For more information about the changes here see the jira.

All the tests pass with this applied. There are still some deprecation warnings but I find some of the test infrastructure is not far enough along so I can't easily address those here.