Split library into lib/
Support parsing all three formats

Move parsing code into the library and refactor to support all three
formats while reducing duplication.
Make some definitions local