Написал прогу, вроде работает, проверьте плиз , если есть возможность добавьте возможность ввода одновременно нескольких правил (у меня проверяет только одно правило например AaaaA->aaaaAaa, а хотелось бы AaaaA->aaaaAaa, АааА->ААаааА, AbabB->BbBAbaa и выдавала тип... )


program grka;

uses crt;

var
s1,s2,s: string;
dl,dr: integer;
i,k,n,p,q: integer;

begin
clrscr;
writeln ('BBEDuTE GPAMMATuKy');
readln (s);
for i:=1 to length(s) do {Tun 0}
if s[i] in ['a'..'z','A'..'Z','>','0'..'9',',','.','\','-'] then
write
else
begin
writeln('HE nPuHaDLeJuT GPAMMATUKE');
break;
end;


for i:=1 to length(s) do
if s[i]='-' then n:=i;

for i:=1 to (n-1) do
begin
s1:=Copy(s,1,n-1);
s2:=Copy(s,n+2,length(s));
end;

dl:=length(s1);
dr:=length(s2);

if dl>dr then write('Tun 0') else
begin
for i:=1 to length(s1) do
begin
if s1[i] in ['a'..'z'] then
begin
if dl<dr then
begin
writeln('Tun 1');
break;
end
else
writeln('Tun 0');
break;
end;
for i:=1 to length(s1) do
if s1[i] in ['a'..'z'] then break; {Pravo}

if not(s1[i+1] in ['a'..'z']) then
if s2[1] in ['a'..'z'] then
begin
for i:=2 to length(s2) do
begin
if s2[i] in ['A'..'Z'] then k:=i ;
if s2[i] in ['a'..'z'] then p:=i;
end;
if (s2[p+1] in ['A'..'Z']) or (s2[k+1] in ['a'..'z'])
then
begin if s2[i] in ['E'] then
writeln('Tun 2 UKS')
else writeln('Tun 2 KS');
end
else writeln('Tun 3 Levostr.');
break;
end;
end;

if s1[i] in ['A'..'Z'] then {left}
if s2[1] in ['A'..'Z'] then
begin
for i:=2 to length(s2) do
begin
if s2[i] in ['a'..'z'] then k:=i;
end;
if (s2[k+1] in ['A'..'Z']) and (s2[p+1] in ['A'..'Z']) then
begin if s2[i] in ['E'] then writeln('Tun 2 UKS')
else writeln('Tun 2 KS')
end
else writeln('Tun 3 Pravostr.');
end;
end;
readkey;
end.