erlang中的基本语法错误

时间:2015-06-26 22:22:41

标签: syntax erlang

我试图在下面的代码中发现语法错误但是我真的无法看到出现了什么问题。我确定它很基本,但我只需要对这段代码有一双新的看法:

sloop(Listen)->
    {ok, Socket} = gen_tcp:accept(Listen),
    io:format("Someone connected"),
    master ! {add,Socket},
    spawn(fun() -> sloop(Listen) end),
    receive
        {tcp, Socket, Bin} ->
             case read(Bin) of
                    {join,Channel} -> 
                        tracker ! {self(),get,Socket},
                        receive 
                            void -> 
                                master ! {delete, Socket},
                                A = lists:dropwhile(fun(A) -> A /= Channel end, resgistered()),
                                case A of
                                    [H|T] -> H ! {add,Socket};
                                    _ -> register(Channel,spawn(fun() -> listenerSocket([]) end))
                                end,
                            Channel ! {add, Socket},
                            tracker ! {insert,Socket, Channel};
                            {ok, Value} -> 
                                Value ! {delete,Socket},
                                tracker ! {delete,Socket},
                                A = lists:dropwhile(fun(A) -> A /= Channel end, resgistered()),
                                case A of
                                    [H|T] -> H ! {add,Socket};
                                    _ -> register(Channel,spawn(fun() -> listenerSocket([]) end))
                                end,
                            Channel ! {add, Socket},
                            tracker ! {insert,Socket, Channel};
                    {message, Msg} ->   
                        tracker ! {self(),get,Socket},
                        receive 
                            {ok, Value} -> Value ! {broadcast, Msg}
                        end
             end;
        {tcp_closed, Socket} -> io:format("Someone disconnected")
    end.

"之前的语法错误。"第50行。 第50行是此代码段的最后一行

1 个答案:

答案 0 :(得分:1)

你错过了end。您显示的最终endcase read(Bin)...匹配,因此封闭receive还需要一个。{/ p>