通过使用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}]
答案 0 :(得分:1)
使用erl_pp:form/1。 这是一个例子:
parse_transform(Forms, _Options) ->
IOList = [erl_pp:form(Form) || Form <- Forms],
io:format(user, "~s", [IOList]),
Forms.
答案 1 :(得分:0)
您可以使用parse_trans应用程序中的漂亮打印机:https://github.com/esl/parse_trans/blob/master/src/parse_trans_pp.erl