Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(esyntax).
- -compile(export_all).
- f() ->
- FunctionBuilder = function_builder(get_send_msg_info),
- ClauseBuilder = clause_builder([], none),
- FunctionBuilder([ClauseBuilder([erl_syntax:atom(abz)])]).
- function_builder(FunctionName) ->
- fun(Clauses) when is_list(Clauses) ->
- erl_syntax:function(erl_syntax:atom(FunctionName), Clauses)
- end.
- clause_builder(Patterns, Guard) ->
- fun(Body) when is_list(Body) ->
- erl_syntax:clause(Patterns, Guard, Body)
- end.
- %%%%%%%%%%%%%
- 102> SyntaxTree = esyntax:f().
- {tree,function,
- {attr,0,[],none},
- {function,{tree,atom,{attr,0,[],none},get_send_msg_info},
- [{tree,clause,
- {attr,0,[],none},
- {clause,[],none,[{tree,atom,{attr,0,[],none},abz}]}}]}}
- 103> erl_syntax:revert(SyntaxTree).
- {function,0,get_send_msg_info,0,
- [{clause,0,[],[],[{atom,0,abz}]}]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement