Refactor parser so it handles input split among multiple chunks.