anchor.diff:  current_pos(#ts{ last     = T })       -> end_pos(pos(T)).
   
   -spec mk_error(#ts{}, term()) -> error().
  -mk_error(Ts, Err) -> {current_pos(Ts), Err}.
  +mk_error(Ts, Err) ->
  +    {current_pos(Ts), Err}.
  +
  +-spec unexpected_token_error(#ts{}, token()) -> error().
  +unexpected_token_error(Ts, T) ->
  +    mk_error(Ts, io_lib:format("Unexpected token ~p", [tag(T)])).
   
   %% Get the next token from a token stream. Inserts layout tokens if necessary.
   -spec next_token(#ts{}) -> false | {token(), #ts{}}.
  
positive.code: parse1({return_plus, X, P}, Ts, Acc,  Err) ->
      case next_token(Ts) of
          false  -> parse1(P, Ts, [X | Acc], Err);
          {T, _} -> parse1(P, Ts, Acc, mk_error(Ts, io_lib:format("Unexpected token ~p", [tag(T)])))
      end;
  parse1({fail, Err}, Ts, Acc, Err1) -> {Acc, add_error(mk_error(Ts, Err), Err1)}.
  
  %% Get the current position of the token stream. This is the position of the next token if any, and
  %% the line after the last token if at the end of the stream.
  
negative.code: -type pos()    :: {integer(), integer()}.
  -type token()  :: {atom(), pos(), term()} | {atom(), pos()}.
  -type tokens() :: [token()].
  -type error()  :: {pos(), string() | no_error}.
  
  -define(lazy(F),     {aeso_parse_lazy, F}).
  -define(fail(Err),   {aeso_parse_fail, Err}).
  