anchor.diff:  %% more/8 and done/6 handles scanning from I/O-server (Stream) or from String.
   %%
   
  -%% String
  -more(Cs, Stack, Toks, {Line, Col}, eos, Errors, _TabWidth, Fun) ->
  -    erlang:error(badstate,
  -		 [Cs, Stack, Toks, {Line, Col}, eos, Errors, Fun]);
  -% %% Debug clause for chopping string into 1-char segments
  -% more(Cs, Stack, Toks, Pos, [H|T], Errors, Fun) ->
  -%     Fun(Cs++[H], Stack, Toks, Pos, T, Errors);
  -more(Cs, Stack, Toks, {Line, Col}, [], Errors, TabWidth, Fun) ->
  -    Fun(Cs ++ eof, Stack, Toks, {Line, Col}, eos, Errors, TabWidth);
  -%% Stream
  -more(Cs, Stack, Toks, {Line, Col}, eof, Errors, TabWidth, Fun) ->
  -    erlang:error(badstate,
  -		 [Cs, Stack, Toks, {Line, Col}, eof, Errors, TabWidth, Fun]);
  -more(Cs, Stack, Toks, {Line, Col}, io, Errors, TabWidth, Fun) ->
  -    {more, {Cs, Stack, Toks, {Line, Col}, io, Errors, TabWidth, Fun}}.
  -
  -%% String
  -done(eof, [], Toks, {Line, Col}, eos, _TabWidth) ->
  -    {ok, reverse(Toks), {Line, Col}};
  -done(eof, Errors, _Toks, {Line, Col}, eos, _TabWidth) ->
  -    {Error, ErrorPos} = lists:last(Errors),
  -    {error, {ErrorPos, ?MODULE, Error}, {Line, Col}};
  -done(Cs, Errors, Toks, {Line, Col}, eos, TabWidth) ->
  -    scan(Cs, [], Toks, {Line, Col}, eos, Errors, TabWidth);
  -% %% Debug clause for chopping string into 1-char segments
  -% done(Cs, Errors, Toks, Pos, [H|T]) ->
  -%    scan(Cs++[H], [], Toks, Pos, T, Errors);
  -done(Cs, Errors, Toks, {Line, Col}, [], TabWidth) ->
  -    scan(Cs ++ eof, [], Toks, {Line, Col}, eos, Errors, TabWidth);
  -%% Stream
  -done(Cs, [], [{dot, _} | _] = Toks, {Line, Col}, io, _TabWidth) ->
  -    {done, {ok, reverse(Toks), {Line, Col}}, Cs};
  -done(Cs, [], [_ | _], {Line, Col}, io, _TabWidth) ->
  -    {done,
  -     {error, {{Line, Col}, ?MODULE, scan}, {Line, Col}}, Cs};
  -done(Cs, [], [], {Line, Col}, eof, _TabWidth) ->
  -    {done, {eof, {Line, Col}}, Cs};
  -done(Cs, [], [{dot, _} | _] = Toks, {Line, Col}, eof, _TabWidth) ->
  -    {done, {ok, reverse(Toks), {Line, Col}}, Cs};
  -done(Cs, [], _Toks, {Line, Col}, eof, _TabWidth) ->
  -    {done,
  -     {error, {{Line, Col}, ?MODULE, scan}, {Line, Col}}, Cs};
  -done(Cs, Errors, _Toks, {Line, Col}, io, _TabWidth) ->
  -    {Error, ErrorPos} = lists:last(Errors),
  -    {done, {error, {ErrorPos, ?MODULE, Error}, {Line, Col}},
  -     Cs};
  -done(Cs, Errors, _Toks, {Line, Col}, eof, _TabWidth) ->
  -    {Error, ErrorPos} = lists:last(Errors),
  -    {done, {error, {ErrorPos, ?MODULE, Error}, {Line, Col}},
  -     Cs}.
  -
  -%% The actual scan loop
  -%% Stack is assumed to be [].
  -
  -scan([$\r | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth) ->      % CR
  -    case Cs of 
  -	[$\n|Cs1] -> 
  -	    scan(Cs1, Stack, [{whitespace, {Line, Col}, '\r\n'}|Toks], {Line + 1, 1}, State, Errors, TabWidth);  
  +scan([$\r | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth, FileFormat) ->    
  +    case FileFormat of 
  +	mac -> 
  +	    scan(Cs, Stack, [{whitespace, {Line, Col}, '\r'}|Toks], {Line + 1, 1}, State, Errors, TabWidth, FileFormat);  
   	_ ->
  -	    scan(Cs, Stack, [{whitespace, {Line, Col}, '\r'}|Toks], {Line + 1, 1}, State, Errors, TabWidth)
  +	    scan(Cs, Stack, [{whitespace, {Line, Col}, '\r'}|Toks], {Line , Col+1}, State, Errors, TabWidth, FileFormat)
       end;
  -scan([$\n | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth) ->      % Newline - skip
  -    scan(Cs, Stack, [{whitespace, {Line, Col}, '\n'}|Toks], {Line + 1, 1}, State, Errors, TabWidth);  
  -
  -%%Begin of Adding by Huiqing
  -scan([C | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth)
  -    when C == $\t
  -	  ->                          
  -    scan(Cs, Stack, [{whitespace, {Line, Col}, '\t'}|Toks], {Line, Col + TabWidth}, State, Errors, TabWidth);
  -%% End of adding by Huiqing
  -
  -scan([C | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth)
  -    when C >= $\000,
  -	 C =< $\s ->                          % Control chars - skip
  -    scan(Cs, Stack, [{whitespace, {Line,Col}, '\s'}|Toks], {Line, Col + 1}, State, Errors, TabWidth);
  -
  -scan([C | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth)
  -    when C >= $\200,
  -	 C =< $\240 ->                        % Control chars -skip
  -    scan(Cs, Stack, [{whitespace, {Line,Col}, '\s'}|Toks], {Line, Col + 1}, State, Errors, TabWidth);
  -scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth)
  -    when C >= $a,
  -	 C =< $z ->                              % Atoms
  -    sub_scan_name(Cs, [C, fun scan_atom/7], Toks,
  -		  {Line, Col}, State, Errors, TabWidth);
  -scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth)
  +scan([$\n | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth, FileFormat) ->    
  +    scan(Cs, Stack, [{whitespace, {Line, Col}, '\n'}|Toks], {Line + 1, 1}, State, Errors, TabWidth,FileFormat);  
  +
  +scan([C | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat)
  +    when C == $\t  ->                          
  +    scan(Cs, Stack, [{whitespace, {Line, Col}, '\t'}|Toks], {Line, Col + TabWidth}, State, Errors, TabWidth,FileFormat);
  +
  +scan([C | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat)
  +    when C >= $\000, C =< $\s ->                          % Control chars - skip
  +    scan(Cs, Stack, [{whitespace, {Line,Col}, '\s'}|Toks], {Line, Col + 1}, State, Errors, TabWidth,FileFormat);
  +
  +scan([C | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat)
  +    when C >= $\200, C =< $\240 ->                        % Control chars -skip
  +    scan(Cs, Stack, [{whitespace, {Line,Col}, '\s'}|Toks], {Line, Col + 1}, State, Errors, TabWidth,FileFormat);
  +scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat)
  +    when C >= $a, C =< $z ->                              % Atoms
  +    sub_scan_name(Cs, [C, fun scan_atom/8], Toks, {Line, Col}, State, Errors, TabWidth,FileFormat);
  +scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat)
       when C >= $, C =< $,
   	 C /= $ ->                     % Atoms
  -    sub_scan_name(Cs, [C, fun scan_atom/7], Toks,
  -		  {Line, Col}, State, Errors, TabWidth);
  -scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth)
  -    when C >= $A,
  -	 C =< $Z ->                              % Variables
  -    sub_scan_name(Cs, [C, fun scan_variable/7], Toks,
  -		  {Line, Col}, State, Errors, TabWidth);
  -scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth)
  -    when C >= $, C =< $,
  -	 C /= $ ->                     % Variables
  -    sub_scan_name(Cs, [C, fun scan_variable/7], Toks,
  -		  {Line, Col}, State, Errors, TabWidth);
  -scan([$_ | Cs], _Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->      % _Variables
  -    sub_scan_name(Cs, [$_, fun scan_variable/7], Toks,
  -		  {Line, Col}, State, Errors, TabWidth);
  -scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth)
  -    when C >= $0,
  -	 C =< $9 ->                            % Numbers
  -    scan_number(Cs, [C], Toks, {Line, Col}, State, Errors, TabWidth);
  -scan([$$ | Cs], Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->        % Character constant
  -    scan_char(Cs, Stack, Toks, {Line, Col+2}, State, Errors, TabWidth);
  -scan([$' | Cs], _Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->      % Quoted atom
  -    scan_qatom(Cs, [$', {Line, Col}], Toks, {Line, Col+1},
  -	       State, Errors, TabWidth);
  -scan([$" | Cs], _Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->      % String
  -    scan_string(Cs, [$", {Line, Col}], Toks, {Line, Col+1},
  -		State, Errors, TabWidth);
  -scan([$% | Cs], _Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->       % Comment
  -    scan_comment(Cs, [$%, {Line, Col}], Toks, {Line, Col+1}, State,
  -		 Errors, TabWidth);
  +    sub_scan_name(Cs, [C, fun scan_atom/8], Toks, {Line, Col}, State, Errors, TabWidth,FileFormat);
  +scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat)
  +    when C >= $A, C =< $Z ->                              % Variables
  +    sub_scan_name(Cs, [C, fun scan_variable/8], Toks, {Line, Col}, State, Errors, TabWidth,FileFormat);
  +scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat)
  +    when C >= $, C =< $, C /= $ ->                     % Variables
  +    sub_scan_name(Cs, [C, fun scan_variable/8], Toks, {Line, Col}, State, Errors, TabWidth,FileFormat);
  +scan([$_ | Cs], _Stack, Toks, {Line, Col}, State,  Errors, TabWidth,FileFormat) ->      % _Variables
  +    sub_scan_name(Cs, [$_, fun scan_variable/8], Toks,  {Line, Col}, State, Errors, TabWidth,FileFormat);
  +scan([C | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat)
  +    when C >= $0, C =< $9 ->                            % Numbers
  +    scan_number(Cs, [C], Toks, {Line, Col}, State, Errors, TabWidth,FileFormat);
  +scan([$$ | Cs], Stack, Toks, {Line, Col}, State,  Errors, TabWidth,FileFormat) ->        % Character constant
  +    scan_char(Cs, Stack, Toks, {Line, Col+2}, State, Errors, TabWidth,FileFormat);
  +scan([$' | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->      % Quoted atom
  +    scan_qatom(Cs, [$', {Line, Col}], Toks, {Line, Col+1}, State, Errors, TabWidth,FileFormat);
  +scan([$" | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->      % String
  +    scan_string(Cs, [$", {Line, Col}], Toks, {Line, Col+1}, State, Errors, TabWidth,FileFormat);
  +scan([$% | Cs], _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->       % Comment
  +    scan_comment(Cs, [$%, {Line, Col}], Toks, {Line, Col+1}, State, Errors, TabWidth,FileFormat);
   %% Punctuation characters and operators, first recognise multiples.
   %% Clauses are rouped by first character (a short with the same head has
   %% to come after a longer).
   %%
   %% << <- <=
  -scan("<<" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'<<', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("<-" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'<-', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("<=" ++ Cs, Stack, Toks, {Line, Col}, State,TabWidth,
  -     Errors) ->
  -    scan(Cs, Stack, [{'<=', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("<" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,
  -	 fun scan/7);
  +scan("<<" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'<<', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan("<-" ++ Cs, Stack, Toks, {Line, Col}, State,  Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'<-', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan("<=" ++ Cs, Stack, Toks, {Line, Col}, State,Errors, TabWidth, FileFormat) ->
  +    scan(Cs, Stack, [{'<=', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth, FileFormat);
  +scan("<" = Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat, fun scan/8);
   %% >> >=
  -scan(">>" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'>>', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan(">=" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'>=', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan(">" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth,
  -	 fun scan/7);
  +scan(">>" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth, FileFormat) ->
  +    scan(Cs, Stack, [{'>>', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth, FileFormat);
  +scan(">=" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'>=', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan(">" = Cs, Stack, Toks, {Line, Col}, State,  Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth, FileFormat, fun scan/8);
   %% -> --
  -scan("->" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'->', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("--" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'--', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("-" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth,
  -	 fun scan/7);
  +scan("->" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'->', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth, FileFormat);
  +scan("--" ++ Cs, Stack, Toks, {Line, Col}, State,  Errors, TabWidth, FileFormat) ->
  +    scan(Cs, Stack, [{'--', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan("-" = Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth, FileFormat, fun scan/8);
   %% ++
  -scan("++" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'++', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("+" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth,
  -	 fun scan/7);
  +scan("++" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'++', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan("+" = Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth, FileFormat, fun scan/8);
   %% =:= =/= =< ==
  -scan("=:=" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'=:=', {Line, Col}} | Toks],
  -	 {Line, Col + 3}, State, Errors, TabWidth);
  -scan("=:" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth,
  -	 fun scan/7);
  -scan("=/=" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'=/=', {Line, Col}} | Toks],
  -	 {Line, Col + 3}, State, Errors, TabWidth);
  -scan("=/" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,
  -	 fun scan/7);
  -scan("=<" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'=<', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("==" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'==', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("=" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth, 
  -	 fun scan/7);
  +scan("=:=" ++ Cs, Stack, Toks, {Line, Col}, State,  Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'=:=', {Line, Col}} | Toks], {Line, Col + 3}, State, Errors, TabWidth,FileFormat);
  +scan("=:" = Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth, FileFormat, fun scan/8);
  +scan("=/=" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'=/=', {Line, Col}} | Toks], {Line, Col + 3}, State, Errors, TabWidth,FileFormat);
  +scan("=/" = Cs, Stack, Toks, {Line, Col}, State,  Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth, FileFormat,fun scan/8);
  +scan("=<" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'=<', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan("==" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'==', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan("=" = Cs, Stack, Toks, {Line, Col}, State,  Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth, FileFormat, fun scan/8);
   %% /=
  -scan("/=" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'/=', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("/" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth,
  -	 fun scan/7);
  +scan("/=" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'/=', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan("/" = Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth,FileFormat, fun scan/8);
   %% ||
  -scan("||" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'||', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  -scan("|" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth,
  -	 fun scan/7);
  +scan("||" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'||', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
  +scan("|" = Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors,TabWidth, FileFormat, fun scan/8);
   %% :-
  -scan(":-" ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack, [{':-', {Line, Col}} | Toks],
  -	 {Line, Col + 2}, State, Errors, TabWidth);
  +scan(":-" ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{':-', {Line, Col}} | Toks], {Line, Col + 2}, State, Errors, TabWidth,FileFormat);
   %% :: for typed records
  -scan("::"++Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth) ->
  -    scan(Cs, Stack, [{'::',{Line, Col}}|Toks], {Line, Col+2}, State, Errors, TabWidth);
  -
  -scan(":" = Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    more(Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,
  -	 fun scan/7);
  +scan("::"++Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{'::',{Line, Col}}|Toks], {Line, Col+2}, State, Errors, TabWidth,FileFormat);
  +
  +scan(":" = Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    more(Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat, fun scan/8);
   %% Full stop and plain '.'
  -scan("." ++ Cs, Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan_dot(Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth);
  +scan("." ++ Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan_dot(Cs, Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat);
   %% All single-char punctuation characters and operators (except '.')
  -scan([C | Cs], Stack, Toks, {Line, Col}, State,
  -     Errors, TabWidth) ->
  -    scan(Cs, Stack,
  -	 [{list_to_atom([C]), {Line, Col}} | Toks],
  -	 {Line, Col + 1}, State, Errors, TabWidth);
  -%%
  -scan([], Stack, Toks, {Line, Col}, State, Errors, TabWidth) ->
  -    more([], Stack, Toks, {Line, Col}, State, Errors, TabWidth,
  -	 fun scan/7);
  -scan(Eof, _Stack, Toks, {Line, Col}, State, Errors, TabWidth) ->
  -    done(Eof, Errors, Toks, {Line, Col}, State, TabWidth).
  -
  -scan_atom(Cs, Name, Toks, {Line, Col}, State, Errors, TabWidth) ->
  +scan([C | Cs], Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    scan(Cs, Stack, [{list_to_atom([C]), {Line, Col}} | Toks],
  +	 {Line, Col + 1}, State, Errors, TabWidth,FileFormat);
  +%%
  +scan([], Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    more([], Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat, fun scan/8);
  +scan(Eof, _Stack, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
  +    done(Eof, Errors, Toks, {Line, Col}, State, TabWidth,FileFormat).
  +
  +scan_atom(Cs, Name, Toks, {Line, Col}, State, Errors, TabWidth,FileFormat) ->
       case catch list_to_atom(Name) of
         Atom when is_atom(Atom) ->
   	  case reserved_word(Atom) of
   	    true ->
  -		scan(Cs, [], [{Atom, {Line, Col}} | Toks],
  -		     {Line, Col + length(Name)}, State, Errors, TabWidth);
  +		  scan(Cs, [], [{Atom, {Line, Col}} | Toks],
  +		     {Line, Col + length(Name)}, State, Errors, TabWidth,FileFormat);
   	    false ->
  -		scan(Cs, [], [{atom, {Line, Col}, Atom} | Toks],
  -		     {Line, Col + length(Name)}, State, Errors, TabWidth)
  +		  scan(Cs, [], [{atom, {Line, Col}, Atom} | Toks],
  +		     {Line, Col + length(Name)}, State, Errors, TabWidth,FileFormat)
   	  end;
         _ ->
   	  scan(Cs, [], Toks, {Line, Col}, State,
  -	       [{{illegal, atom}, {Line, Col}} | Errors], TabWidth)
  +	       [{{illegal, atom}, {Line, Col}} | Errors],TabWidth,FileFormat)
       end.
   
   scan_variable(Cs, Name, Toks, {Line, Col}, State,
  -	      Errors, TabWidth) ->
  +	      Errors, TabWidth,FileFormat) ->
       case catch list_to_atom(Name) of
         A when is_atom(A) ->
   	  scan(Cs, [], [{var, {Line, Col}, A} | Toks],
  -	       {Line, Col + length(Name)}, State, Errors, TabWidth);
  +	       {Line, Col + length(Name)}, State, Errors, TabWidth,FileFormat);
         _ ->
   	  scan(Cs, [], Toks, {Line, Col}, State,
  -	       [{{illegal, var}, {Line, Col}} | Errors], TabWidth)
  +	       [{{illegal, var}, {Line, Col}} | Errors], TabWidth,FileFormat)
       end.
   
   %% Scan for a name - unqouted atom or variable, after the first character.
  
positive.code: 
  -module(refac_scan_with_layout).
  
  -export([string/1,string/2,string/3, tokens/3]).
  
  -import(lists, [member/2, reverse/1]).
  
  -define(DEFAULT_TABWIDTH, 8).
  
  %% string(CharList, StartPos)
  %%  Takes a list of characters and tries to tokenise them.
  
negative.code: 
  
  string(Cs) ->
      string(Cs, {1, 1}, ?DEFAULT_TABWIDTH, ?DEFAULT_FILEFORMAT).
  
  string(Cs, {Line, Col}) -> string(Cs, {Line, Col}, ?DEFAULT_TABWIDTH, ?DEFAULT_FILEFORMAT).
  
  string(Cs, {Line, Col}, TabWidth, FileFormat)
      when is_list(Cs), is_integer(Line), is_integer(Col), is_integer(TabWidth) ->
      %     %% Debug replacement line for chopping string into 1-char segments
      %     scan([], [], [], Pos, Cs, []).
      scan(Cs, [], [], {Line, Col}, [], [],TabWidth,FileFormat).
  
  
  %% String
  more(Cs, Stack, Toks, {Line, Col}, eos, Errors, _TabWidth, _FileFormat, Fun) ->
      erlang:error(badstate, [Cs, Stack, Toks, {Line, Col}, eos, Errors, Fun]);
  % %% Debug clause for chopping string into 1-char segments
  % more(Cs, Stack, Toks, Pos, [H|T], Errors, Fun) ->
  %     Fun(Cs++[H], Stack, Toks, Pos, T, Errors);
  more(Cs, Stack, Toks, {Line, Col}, [], Errors, TabWidth, FileFormat, Fun) ->
      Fun(Cs ++ eof, Stack, Toks, {Line, Col}, eos, Errors, TabWidth,FileFormat);
  %% Stream
  more(Cs, Stack, Toks, {Line, Col}, eof, Errors, TabWidth, FileFormat, Fun) ->
      erlang:error(badstate, [Cs, Stack, Toks, {Line, Col}, eof, Errors, TabWidth, FileFormat, Fun]);
  more(Cs, Stack, Toks, {Line, Col}, io, Errors, TabWidth, FileFormat, Fun) ->
      {more, {Cs, Stack, Toks, {Line, Col}, io, Errors,TabWidth, FileFormat, Fun}}.
  
  
  %% Scan loop.
  %%
  