无法找到语法错误,我搜索了放错位置/缺少“;”的位置,“,”,“结尾”,还搜索缺少的括号但没有运气。
有任何想法吗?
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).
最佳答案
您在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
子句中编写代码。