anchor.diff:      end.
   
   -spec reset_parser(parser()) -> {ok, parser()} | {error, any()}.
  -reset_parser(#parser{event_parser = EventParser}) ->
  +reset_parser(#parser{event_parser = EventParser, type = Type}) ->
       try
           exml_event:reset_parser(EventParser),
           %% drop all the state except event_parser
  -        {ok, #parser{event_parser = EventParser}}
  +        {ok, prepare_parser(#parser{event_parser = EventParser, type = Type})}
       catch
           E:R ->
               {error, {E, R}}
  
positive.code: %%%===================================================================
  %%% Helpers
  %%%===================================================================
  
  -spec parse_events(list(), list(), list()) -> {list(xmlstreamelement()), list()}.
  parse_events([], Stack, Acc) ->
  
negative.code: -include("exml_stream.hrl").
  
  -export([new_parser/0,
           new_parser/1,
           parse/2,
           reset_parser/1,
           free_parser/1]).
  -export_type([parser/0]).
  -export_type([parser_type/0]).
  
  %% single_doc - the old way one document: <stream:stream> ..... </stream:stream>
  %% multiple_docs - xmpp over websockets(IETF 89) replaces <stream:..> tags with
  %% <open/> <close/>. As a result we have a stream of multiple xml documents instead of one document.
  %% This type of parser can handle that stream.
  %% see: http://datatracker.ietf.org/doc/draft-ietf-xmpp-websocket/?include_text=1
  -type parser_type() :: single_doc | multiple_docs.
  
  -record(parser, {
          event_parser,
          type,
          stack = []
  }).
  
  