【问题标题】:How to generate AST for a module in erlang?如何为erlang中的模块生成AST?
【发布时间】:2021-12-16 17:25:48
【问题描述】:

如何在运行时为整个模块生成 AST?

【问题讨论】:

    标签: erlang abstract-syntax-tree


    【解决方案1】:

    有多种方法可以实现这一目标。

    例如,您可以像我们在the rebar3 formatter 上一样使用ktn_dodger

    但是,只有 OTP……

    1> epp_dodger:quick_parse_file("src/pt_example.erl").
    {ok,[{attribute,1,module,pt_example},
         {attribute,3,export,[{a,0}]},
         {function,5,a,0,
                   [{clause,5,[],[],
                            [{call,6,
                                   {remote,6,{atom,6,io},{atom,6,format}},
                                   [{string,6,"Hello!"}]}]}]}]}
    

    【讨论】:

      猜你喜欢
      • 2016-08-07
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      • 1970-01-01
      • 1970-01-01
      • 2015-04-16
      • 1970-01-01
      • 2019-05-27
      相关资源
      最近更新 更多