SHOW:
|
|
- or go back to the newest paste.
| 1 | -module(esyntax). | |
| 2 | -compile(export_all). | |
| 3 | ||
| 4 | f() -> | |
| 5 | FunctionBuilder = function_builder(get_send_msg_info), | |
| 6 | ClauseBuilder = clause_builder([], none), | |
| 7 | - | FunctionBuilder(ClauseBuilder(erl_syntax:list(erl_syntax:atom(abz)))). |
| 7 | + | FunctionBuilder([ClauseBuilder([erl_syntax:atom(abz)])]). |
| 8 | ||
| 9 | function_builder(FunctionName) -> | |
| 10 | - | fun(Clauses) -> |
| 10 | + | fun(Clauses) when is_list(Clauses) -> |
| 11 | erl_syntax:function(erl_syntax:atom(FunctionName), Clauses) | |
| 12 | end. | |
| 13 | ||
| 14 | clause_builder(Patterns, Guard) -> | |
| 15 | - | fun(Body) -> |
| 15 | + | fun(Body) when is_list(Body) -> |
| 16 | erl_syntax:clause(Patterns, Guard, Body) | |
| 17 | end. | |
| 18 | ||
| 19 | %%%%%%%%%%%%% | |
| 20 | ||
| 21 | - | 55> SyntaxTree = esyntax:f(). |
| 21 | + | 102> SyntaxTree = esyntax:f(). |
| 22 | {tree,function,
| |
| 23 | - | {attr,0,[],none},
|
| 23 | + | {attr,0,[],none},
|
| 24 | - | {function,
|
| 24 | + | {function,{tree,atom,{attr,0,[],none},get_send_msg_info},
|
| 25 | - | {tree,atom,{attr,0,[],none},get_send_msg_info},
|
| 25 | + | [{tree,clause,
|
| 26 | - | {tree,clause,
|
| 26 | + | {attr,0,[],none},
|
| 27 | - | {attr,0,[],none},
|
| 27 | + | {clause,[],none,[{tree,atom,{attr,0,[],none},abz}]}}]}}
|
| 28 | - | {clause,[],none,
|
| 28 | + | 103> erl_syntax:revert(SyntaxTree). |
| 29 | - | {tree,list,
|
| 29 | + | {function,0,get_send_msg_info,0,
|
| 30 | - | {attr,0,[],none},
|
| 30 | + | [{clause,0,[],[],[{atom,0,abz}]}]} |