anchor.diff:      end.
   
   %% Errors.
  +format_error({notrans_function,F,A}) ->
  +    io_lib:format("unable to translate function ~w/~w", [F,A]);
   format_error({notrans_record,R}) ->
       io_lib:format("unable to translate record ~w", [R]);
   format_error({notrans_macro,M}) ->
       io_lib:format("unable to translate macro ~w", [M]).
  +
  +%% add_warning(Warning, State) -> State.
  +%% add_warning(Line, Warning, State) -> State.
  +
  +add_warning(W, St) -> add_warning(St#mac.line, W, St).
  +
  +add_warning(L, W, St) ->
  +    St#mac{warnings=St#mac.warnings ++ [{L,?MODULE,W}]}.
   
   %% file([FileName], Env, State) -> {yes,(progn ...),State} | no.
   %%  Expand the (include-file ...) macro.  This is a VERY simple
  
positive.code: 
  %% parse_hrl_file(Forms, Macros, State) -> {ok,Forms,State} | {error,Error}.
  
  parse_hrl_file(Fs0, Ms0, St) ->
      Fs1 = trans_forms(Fs0),
      Ms1 = trans_macros(Ms0),
      {ok,Fs1 ++ Ms1,St}.
  
  %% trans_forms(Forms) -> Forms.
  %%  Translate the record defintions in the forms to LFE record
  %%  definitions. Ignore all type declarations and other forms.
  
  trans_forms([{attribute,_,record,{Name,Fields}}|Fs]) ->
      Rs = record_fields(Fields),
      [[defrecord,Name|Rs]|trans_forms(Fs)];
  trans_forms([{error,_}|Fs]) -> trans_forms(Fs);	%What should we do with these?
  trans_forms([_|Fs]) -> trans_forms(Fs);		%Ignore everything else
  trans_forms([]) -> [].
  
  record_fields(Fs) ->
      [ record_field(F) || F <- Fs ].
  
negative.code:     Ld = lfe_trans:from_expr(Def),
      [Fd,Ld].
  
  %% trans_function(Name, Arity, Clauses) -> LfuncDef.
  
  trans_function(Name, _, Cls) ->
      %% Make it a fun and then drop the match-lambda.
      ['match-lambda'|Lcs] = lfe_trans:from_expr({'fun',0,{clauses,Cls}}),
      [defun,Name|Lcs].
  
  %% trans_macros(MacroDefs, State) -> {LMacroDefs,State}.
  %%  Translate macro definitions to LFE macro definitions. Ignore
  %%  undefined and predefined macros.
  
  trans_macros([{{atom,Mac},Defs}|Ms], St0) ->
      {Lms,St1} = trans_macros(Ms, St0),
      case catch trans_macro(Mac, Defs, St1) of
  	{'EXIT',_} ->				%It crashed
  	    {Lms,add_warning({notrans_macro,Mac}, St1)};
  	{none,St2} -> {Lms,St2};		%No definition, ignore
  	{Mdef,St2} -> {[Mdef|Lms],St2}
      end;
  trans_macros([], St) -> {[],St}.
  
  trans_macro(_, undefined, St) -> {none,St};	%Undefined macros
  trans_macro(_, {none,_}, St) -> {none,St};	%Predefined macros
  trans_macro(Mac, Defs0, St) ->
      Defs1 = order_macro_defs(Defs0),
      case trans_macro_defs(Defs1) of
  	[] -> {none,St};			%No definitions
  	Lcls -> {[defmacro,Mac|Lcls],St}
      end.
  
  order_macro_defs([{none,Ds}|Defs]) ->		%Put the no arg version last
      Defs ++ [{none,Ds}];
  order_macro_defs(Defs) -> Defs.
  
  %% trans_macro_defs(MacroDef) -> [] | [Clause].
  %%  Translate macro definition to a list of clauses. Put the no arg
  %%  version last as a catch all. Clash if macro has no arg definition
  %%  *and* function definition with no args:
  