Add finish_parsing function.

@caitp or @rillian please review.

I've added the finish_parsing function. Based on these changes the calling application
will now call this function when the stream has come to an end and the parser should
do it's final operations.