anchor.diff:  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
  +%% pass_fileforms(FileForms, Env, State) -> {FileForms,Env,State}.
  +%% pass_forms(Forms, Env, State) -> {Forms,Env,State}.
  +%%  Pass over a list of fileforms/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) ->
  +pass_fileforms(Ffs, Env, St) ->
  +    mapfoldl2(fun ({F0,L}, E0, S0) ->
  +                      {F1,E1,S1} = pass_form(F0, E0, S0#mac{line=L}),
  +                      %%io:format("p: ~p\n" ,[{F0,F1,L}]),
  +                      {{F1,L},E1,S1}
  +              end, Env, St, Ffs).
  +
  +pass_forms(Fs, Env, St) ->
  +    mapfoldl2(fun (F0, E0, S0) -> pass_form(F0, E0, S0) end, Env, St, Fs).
  +
  +%% pass_form(Form, Env, State) -> {Form,Env,State}.
  +%%  Do a form collecting and removing all macro defintions. The form
  +%%  must be expanded at top-level to check it, but it can be expanded
  +%%  to full depth. Nesting of forms by progn is preserved.
  +
  +pass_form(['progn'|Pfs0], Env0, St0) ->
  +    {Pfs1,Env1,St1} = pass_forms(Pfs0, Env0, St0),
  +    {['progn'|Pfs1],Env1,St1};
  +pass_form(['eval-when-compile'|Ewcs0], 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) ->
  +    {['progn'|Ecws1],Env1,St1};
  +pass_form(['define-macro'|Def]=F, Env0, St0) ->
       case pass_define_macro(Def, Env0, St0) of
  -        {yes,Env1,St1} -> pass_progn(Fs0, Env1, St1);
  +        {yes,Env1,St1} ->
  +            {['progn'],Env1,St1};               %Must return a valid form
           {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) ->
  +            {F,Env0,St1}
  +    end;
  +pass_form(F, Env, St0) ->
       %% First expand enough to test top form, if so process again.
  -    case pass_expand_expr(F, Env0, St0, St0#mac.expand) of
  +    case pass_expand_expr(F, Env, St0, St0#mac.expand) of
           {yes,Exp,St1} ->                        %Top form expanded
  -            pass_progn([Exp|Fs0], Env0, St1);
  +            pass_form(Exp, Env, 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}.
  +            {F1,Env,St1}
  +    end.
   
   %% pass_ewc(Forms, Env, State) -> {Forms,Env,State}.
   %%  Pass over a list of forms collecting and removing all function
  
positive.code: 
  -import(lists, [any/2,all/2,map/2,foldl/3,foldr/3,mapfoldl/3,
                  reverse/1,reverse/2,member/2,concat/1]).
  -import(orddict, [find/2,store/3]).
  -import(ordsets, [add_element/2,is_element/2]).
  
  -include("lfe_comp.hrl").
  -include("lfe_macro.hrl").
  
negative.code:     do_forms(Fs, Env, St).
  
  do_forms(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}
  