Skip to content

Commit

Permalink
shen
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Apr 12, 2014
1 parent 1b9a8cd commit 3a01f30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions priv/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ var start = pattern({
var fac = pattern({
'0': function(_0) {
return 1;
},
'n': function(n) {
}, 'n': function(n) {
return n * fac(n - 1);
}});
start();
5 changes: 3 additions & 2 deletions src/shen.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ compile(_Form,_) -> ":-)".
function(Name,X,Args,Clauses,Type) ->
case Type of
compile -> [ io_lib:format("var ~s = pattern({~n", [ Name ]),
string:join([ clause(Args,C,Type) || C <- Clauses ],",\n"),
string:join([ clause(Args,C,Type) || C <- Clauses ],","),
io_lib:format("~s~n",["});"]) ];
match -> [ io_lib:format("pattern({~n",[]),
string:join([ clause(Args,C,{match,Name}) || C <- Clauses ],",\n"),
Expand Down Expand Up @@ -124,12 +124,13 @@ normalize_list({cons,_X,Left,Right},L,Mode) -> [{exp(Left,Mode)},normalize_list(

arg({integer,_X,_Value},_N) -> io_lib:format("_~s",[integer_to_list(_Value)]);
arg({string,_X,_Value},N) -> io_lib:format("~s",[N]);
arg({atom,_X,_Value},N) -> io_lib:format("~p",[N]);
arg({atom,_X,_Value},N) -> io_lib:format("'~s'",[N]);
arg({var,_X,Value},_N) -> io_lib:format("~s",[string:to_lower(atom_to_list(Value))]).

par(List,Mode) -> io_lib:format("~s",[lists:flatten(string:join([exp(V,Mode)||V<-List],","))]).

exp({integer,_X,Value},_) -> io_lib:format("~s",[integer_to_list(Value)]);
exp({binary,_X,Value},_) -> io_lib:format("~s",[binary_to_list(Value)]);
exp({string,_X,Value},_) -> io_lib:format("'~s'",[Value]);
exp({atom,_X,Value},{inline,_}) -> io_lib:format("'~w'",[Value]);
exp({atom,_X,Value},_) -> io_lib:format("~w",[Value]);
Expand Down

0 comments on commit 3a01f30

Please sign in to comment.