anchor.diff:      do_forms(Fs, Env, St).
   
   do_forms(Fs0, Env0, St0) ->
  -    {Fs1,Env1,St1} = pass(Fs0, Env0, St0),
  +    {Fs1,Env1,St1} = pass_fileforms(Fs0, Env0, St0),
       case St1#mac.errors of
           [] -> {ok,Fs1,Env1,St1#mac.warnings};    %No errors
           Es -> {error,Es,St1#mac.warnings}
  
positive.code: default_state(Expand) ->
      #mac{expand=Expand,line=1,file="-nofile-",opts=[],ipath=["."]}.
  
  %% pass(FileForms, Env, State) -> {FileForms,Env,State}.
  %%  Pass over a list of fileforms, {Form,Line}, collecting and
  %%  removing all macro defintions. All forms must be expanded at
  %%  top-level to check form, but all can be expanded to full depth.
  %%  Nesting of forms by progn is preserved.
  
  pass([{['progn'|Pfs0],L}|Fs0], Env0, St0) ->
      {Pfs1,Env1,St1} = pass_progn(Pfs0, Env0, St0#mac{line=L}),
      {Fs1,Env2,St2} = pass(Fs0, Env1, St1),
      {[{['progn'|Pfs1],L}|Fs1],Env2,St2};
  pass([{['eval-when-compile'|Ewcs0],L}|Fs0], Env0, St0) ->
      {Ecws1,Env1,St1} = pass_ewc(Ewcs0, Env0, St0#mac{line=L}),
      {Fs1,Env2,St2} = pass(Fs0, Env1, St1),
      {[{['progn'|Ecws1],L}|Fs1],Env2,St2};
  pass([{['define-macro'|Def]=F,L}|Fs0], Env0, St0) ->
      case pass_define_macro(Def, Env0, St0#mac{line=L}) of
          {yes,Env1,St1} -> pass(Fs0, Env1, St1);
          {no,St1} ->
              %% Ignore it and pass it on to generate error later.
              {Fs1,Env1,St2} = pass(Fs0, Env0, St1),
              {[{F,L}|Fs1],Env1,St2}
      end;
  pass([{F,L}|Fs0], Env0, St0) ->
      %% First expand enough to test top form, else maybe expand all.
      case pass_expand_expr(F, Env0, St0#mac{line=L}, St0#mac.expand) of
          {yes,Exp,St1} ->            %Top form expanded
              pass([{Exp,L}|Fs0], Env0, St1);
          {no,F1,St1} ->                 %Expanded all if flag set
              {Fs1,Env1,St2} = pass(Fs0, Env0, St1),
              {[{F1,L}|Fs1],Env1,St2}
      end;
  pass([], Env, St) -> {[],Env,St}.
  
  %% pass_progn(Forms, Env, State) -> {Forms,Env,State}.
  %%  Pass over a list of forms collecting and removing all macro
  %%  defintions. All forms must be expanded at top-level to check form,
  %%  but all can be expanded to full depth. Nesting of forms by progn
  %%  is preserved.
  
  pass_progn([['progn'|Pfs0]|Fs0], Env0, St0) ->
      {Pfs1,Env1,St1} = pass_progn(Pfs0, Env0, St0),
      {Fs1,Env2,St2} = pass_progn(Fs0, Env1, St1),
      {[['progn'|Pfs1]|Fs1],Env2,St2};
  pass_progn([['eval-when-compile'|Ewcs0]|Fs0], Env0, St0) ->
      {Ecws1,Env1,St1} = pass_ewc(Ewcs0, Env0, St0),
      {Fs1,Env2,St2} = pass_progn(Fs0, Env1, St1),
      {[['progn'|Ecws1]|Fs1],Env2,St2};
  pass_progn([['define-macro'|Def]=F|Fs0], Env0, St0) ->
      case pass_define_macro(Def, Env0, St0) of
          {yes,Env1,St1} -> pass_progn(Fs0, Env1, St1);
          {no,St1} ->
              %% Ignore it and pass it on to generate error later.
              {Fs1,Env1,St2} = pass_progn(Fs0, Env0, St1),
              {[F|Fs1],Env1,St2}
      end;
  pass_progn([F|Fs0], Env0, St0) ->
      %% First expand enough to test top form, if so process again.
      case pass_expand_expr(F, Env0, St0, St0#mac.expand) of
          {yes,Exp,St1} ->                        %Top form expanded
              pass_progn([Exp|Fs0], Env0, St1);
          {no,F1,St1} ->                          %Expanded all if flag set
              {Fs1,Env1,St2} = pass_progn(Fs0, Env0, St1),
              {[F1|Fs1],Env1,St2}
      end;
  pass_progn([], Env, St) -> {[],Env,St}.
  
  %% pass_ewc(Forms, Env, State) -> {Forms,Env,State}.
  %%  Pass over a list of forms collecting and removing all function
  
negative.code: %% Errors
  format_error({bad_form,Type}) ->
      lfe_io:format1("bad form: ~w", [Type]);
  format_error({bad_env_form,Type}) ->
      lfe_io:format1("bad environment form: ~w", [Type]);
  format_error({expand_macro,Call,_}) ->
      %% Can be very big so only print limited depth.
      lfe_io:format1("error expanding ~P", [Call,10]).
  