1

parse_transを使用することで、モジュールのフォームを取得しています。次に、モジュールにいくつかの変更を加えています。フォームを実際のerlangコードに変換する方法はありますか?フォームは次のとおりです。

[{attribute,1,file,
        {"/program.erl",
         1}},
{attribute,1,module,program},
{attribute,3,export,[{run,0}]},
{function,5,run,0,
       [{clause,5,[],[],
                [{match,5,
                        {var,5,'T'},
                        {cons,5,
                              {atom,40,program},
                              {cons,5,{atom,40,...},{cons,...}}}},
                 {call,5,
                       {remote,5,{atom,5,advices},{atom,5,before_advice}},
                       [{var,5,'T'}]},
                 {match,5,{var,5,'R'},{call,5,{atom,5,run_@},[]}},
                 {var,5,'R'}]}]},
{function,5,run_@,0,
       [{clause,5,[],[],
                [{call,6,
                       {remote,6,{atom,6,program2},{atom,6,calc_service}},
                       [{integer,6,1},{integer,6,0}]},
                 {call,7,
                       {remote,7,{atom,7,program2},{atom,7,calc_service}},
                       [{integer,7,2},{integer,7,2}]},
                 {call,8,
                       {remote,8,{atom,8,program2},{atom,8,process_message}},
                       [{string,8,"Add 3 to 5"}]},
                 {call,9,
                       {remote,9,{atom,9,program2},{atom,9,...}},
                       [{string,9,"Message to process"}]},
                 {call,10,{remote,10,{atom,10,...},{atom,...}},[]},
                 {atom,11,ok}]}]},
{eof,11}]
4

2 に答える 2

1

erl_pp:form/1を使用します。次に例を示します。

parse_transform(Forms, _Options) ->
    IOList = [erl_pp:form(Form) || Form <- Forms],
    io:format(user, "~s", [IOList]),
    Forms.
于 2013-03-15T09:38:32.547 に答える
0

parse_transアプリケーションからpretty-printerを使用できます:https ://github.com/esl/parse_trans/blob/master/src/parse_trans_pp.erl

于 2013-03-14T06:56:20.140 に答える