anchor.diff:      ImportedGrpRecs = [{M, a_record(Prefix, fun grp_proj/1, Gs)}
                          || {M,Gs} <- get_value(import_groups, Spec)],
   
  -    {Prefix, MsgRecs, GrpRecs, ImportedGrpRecs}.
  +    {to_upper(Prefix), MsgRecs, GrpRecs, ImportedGrpRecs}.
   
   msg_proj({Name, _, _, _, Avps}) ->
       {Name, Avps}.
  
positive.code:      [{?clause, [], [], [?TERM([?VERSION | Spec])]}]}.
  
  %%% ------------------------------------------------------------------------
  %%% # gen_hrl/3
  %%% ------------------------------------------------------------------------
  
  gen_hrl(Path, Mod, Spec) ->
      {ok, Fd} = file:open(Path, [write]),
  
      {Prefix, MsgRecs, GrpRecs, ImportedGrpRecs}
          = make_record_forms(Spec),
  
      file:write(Fd, hrl_header(Mod)),
  
      forms("Message records",     Fd, MsgRecs),
      forms("Grouped AVP records", Fd, GrpRecs),
  
      lists:foreach(fun({M,Fs}) ->
                            forms("Grouped AVP records from " ++ atom_to_list(M),
                                  Fd,
                                  Fs)
                    end,
                    ImportedGrpRecs),
  
      PREFIX = to_upper(Prefix),
  
      write("ENUM Macros",
            Fd,
            m_enums(PREFIX, false, get_value(enum, Spec))),
      write("DEFINE Macros",
            Fd,
            m_enums(PREFIX, false, get_value(define, Spec))),
  
      lists:foreach(fun({M,Es}) ->
                            write("ENUM Macros from " ++ atom_to_list(M),
                                  Fd,
                                  m_enums(PREFIX, true, Es))
                    end,
                    get_value(import_enums, Spec)),
  
      file:close(Fd).
  
  forms(_, _, []) ->
      ok;
  forms(Banner, Fd, Forms) ->
      write(Banner, Fd, prettypr(Forms)).
  
  write(_, _, []) ->
      ok;
  write(Banner, Fd, Str) ->
      banner(Fd, Banner),
      io:fwrite(Fd, "~s~n", [Str]).
  
  prettypr(Forms) ->
      erl_prettypr:format(erl_syntax:form_list(Forms)).
  
  banner(Fd, Heading) ->
      file:write(Fd, banner(Heading)).
  
  banner(Heading) ->
      ("\n\n"
       "%%% -------------------------------------------------------\n"
       "%%% " ++ Heading ++ ":\n"
       "%%% -------------------------------------------------------\n\n").
  
  z(S) ->
      string:join(string:tokens(S, "\s\t"), "\s").
  
negative.code:     write_term(Path ++ ".D", [?VERSION | Spec]);
  
  gen(hrl, Spec, Mod, Path) ->
      write(Path ++ ".hrl", gen_hrl(Mod, Spec));
  
  gen(erl, Spec, Mod, Path) ->
      Forms = erl_forms(Mod, Spec),
      getr(debug) andalso write_term(Path ++ ".F", [Forms]),
      write(Path ++ ".erl", [header(), prettypr(Forms), $\n]).
  
  write(Path, T) ->
      write(Path, "~s", T).
  
  write_term(Path, T) ->
      write(Path, "~p.~n", T).
  
  write(Path, Fmt, T) ->
      {ok, Fd} = file:open(Path, [write]),
      io:fwrite(Fd, Fmt, [T]),
      file:close(Fd).
  
  erl_forms(Mod, Spec) ->
      Forms = [[{?attribute, module, Mod},
                {?attribute, compile, {parse_transform, diameter_exprecs}},
                {?attribute, compile, nowarn_unused_function}],
               make_hrl_forms(Spec),
               [{?attribute, export, [{name, 0},
                                      {id, 0},
                                      {vendor_id, 0},
                                      {vendor_name, 0},
                                      {decode_avps, 2}, %% in diameter_gen.hrl
                                      {encode_avps, 2}, %%
                                      {msg_name, 2},
                                      {msg_header, 1},
                                      {rec2msg, 1},
                                      {msg2rec, 1},
                                      {name2rec, 1},
                                      {avp_name, 2},
                                      {avp_arity, 2},
                                      {avp_header, 1},
                                      {avp, 3},
                                      {grouped_avp, 3},
                                      {enumerated_avp, 3},
                                      {empty_value, 1},
                                      {dict, 0}]},
                %% diameter.hrl is included for #diameter_avp
                {?attribute, include_lib, "diameter/include/diameter.hrl"},
                {?attribute, include_lib, "diameter/include/diameter_gen.hrl"},
                f_name(Mod),
                f_id(Spec),
                f_vendor_id(Spec),
                f_vendor_name(Spec),
                f_msg_name(Spec),
                f_msg_header(Spec),
                f_rec2msg(Spec),
                f_msg2rec(Spec),
                f_name2rec(Spec),
                f_avp_name(Spec),
                f_avp_arity(Spec),
                f_avp_header(Spec),
                f_avp(Spec),
                f_enumerated_avp(Spec),
                f_empty_value(Spec),
                f_dict(Spec),
                {eof, ?LINE}]],
  
      lists:append(Forms).
  
  make_hrl_forms(Spec) ->
      {_Prefix, MsgRecs, GrpRecs, ImportedGrpRecs}
  