Refactor the parser to operate line based

* Previously attempted to operate element based, however this
  caused issues because elements cannot be determined accurately
  without parsing the entire line.
* Line based will make it easier for callers to reason about
  whether there will be a malloc+memcpy or not.
* Logic is greatly simplified as part of the refactor.
Merge pull request #21 from dstufft/refactor-to-line-based

Refactor the parser to operate line based