Erlang语法错误出现在第55行:“ end”

时间:2018-07-14 21:20:08

标签: erlang syntax-error

无法找到语法错​​误,我搜索了放错位置/缺少“;”的位置,“,”,“结尾”,还搜索缺少的括号但没有运气。 有什么想法吗?

PD:对不起,英语和西班牙语代码错误

partida(ID,Tablero,Turno,Name1,Psocket1,Name2,Psocket2,SpectList) ->
 case (Psocket1 == " ") of
 true -> F = fun() -> case mnesia:read(juegos,ID) of
        [P1] ->
            case mnesia:read(nombre,P1#juegos.jg1) of
                [] -> exit(normal);
                [A] -> P2 = A#nombre.psocket
            end,
            case mnesia:read(nombre,P1#juegos.jg2) of
                [] -> exit(normal);
                [B] -> P3 = B#nombre.psocket
            end,
            Res = {P1#juegos.jg1,P2,P1#juegos.jg2,P3,P1#juegos.spect};
         _  -> Res = ok,exit(normal)                         
        end,
        Res end,
        {atomic,Arg} = mnesia:transaction(F),
        partida(ID,Tablero,Turno,element(1,Arg),element(2,Arg),element(3,Arg),element(4,Arg),element(5,Arg))
end,
receive
    case Jugada of
        [Pj,"bye"] -> ok;
        [Pj,F]   -> Posicion = element(1,string:to_integer(F)),
                    case (Name1 == Pj) and ((Turno rem 2) == 1) of
                        true -> case not(Posicion == error) and  (Posicion < 10) of
                                    true -> ok;%%jugada valida
                                    _  -> ok %%Jugada ilegal
                                end;
                        false ->ok %%No es tu turno
                    end,
                    case (Name2 == Pj) and ((Turno rem 2) == 0) of
                        true -> case (not(Posicion == error) and (Posicion < 10)) of
                                    true ->ok; %%jugada valida
                                     _ -> ok %%Jugada ilegal
                                end;
                        false -> ok %%No es tu turno
                    end
    end
end, %% Line 55
ASD = get_spects(ID),partida(ID,Tablero,Turno,Name1,Psocket1,Name2,Psocket2,ASD).

1 个答案:

答案 0 :(得分:1)

您在receive子句中有语法错误。

1> case oops of _ -> ok end. % correct
ok
2> receive (case oops of _ -> ok end) end.
* 1: syntax error before: 'end'

receive语句用于读取进程的Erlang消息。在这里,您无需等待任何消息,而可以在receive子句的主体中执行某些操作!如果您不想查看消息,但是想要在收到第一条消息后做一些事情,我建议使用_进行模式匹配:

3> receive _ -> (case oops of _ -> ok end) end.
%% Waits for a message

实际上,您没有receive子句,但是像这样:

4> receive after 1000 -> done end. %% Sleeps 1000 ms and does not care about any incoming message
done

但是如果没有任何模式匹配,就不能在receive子句中编写代码。