![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Ошибка при работе со строковыми переменными? [D6]
Lexa © (2005-08-01 06:57:00)Судари, может кто на свежую голову разглядит ошибку в процедуре?
У меня просто уже в глазах рябит... Никаких Exception'ов не возникает - не работает и все. Ерунда какая-нибудь - точно.
"Зоны риска" выделю Bold'ом, точнее одну - они аналогичны. Заранее благодарю всех, кто решит напрячься.
procedure unification(F1,F2,S1,S2: string; DC1: TDIPcre; L: TLabel);
var
str1, str2: string;
lg1,lg2: integer;
fc: string;
y1,y2: integer;
begin
DC1.MatchPattern := '\S';
DC1.SetSubjectStr(F1);
DC1.Match(1);
if DC1.SubStrCount < 1 then
begin
DC1.MatchPattern := '\S';
DC1.SetSubjectStr(F2);
DC1.Match(1);
if DC1.SubStrCount < 1 then
begin
L.Caption := fc;
end
else
begin
L.Caption := 'no1';
end;
end
else
begin
str1 := DC1.MatchedStr;
lg1 := DC1.MatchedStrLength;
DC1.MatchPattern := '\S';
DC1.SetSubjectStr(F2);
DC1.Match(1);
if DC1.SubStrCount < 1 then
begin
L.Caption := 'no2';
end
else
begin
str2 := DC1.MatchedStr;
lg2 := DC1.MatchedStrLength;
if str1 = str2 then
begin
fc := fc + str1;
delete(F1, 2, lg1);
delete(F2, 2, lg2);
unification(F1, F2, S1, S2, L);
end
else //Символы не совпадают
begin //1 символ 1 формулы - временная переменная?
DC1.MatchPattern := 't\d+';
DC1.SetSubjectStr(F1);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin //1 символ 2 формулы - временная переменная?
str1 := ' '+DC1.MatchedStr;
lg1 := DC1.MatchedStrLength;
DC1.MatchPattern := 't\d+';
DC1.SetSubjectStr(F2);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin //Ищем временную переменную с меньшим индексом
str2 := ' '+DC1.MatchedStr;
lg2 := DC1.MatchedStrLength;
DC1.MatchPattern := '\d+';
DC1.SetSubjectStr(str1);
DC1.Match(1);
y1 := StrToInt(DC1.MatchedStr);
DC1.MatchPattern := '\d+';
DC1.SetSubjectStr(str2);
DC1.Match(1);
y2 := StrToInt(DC1.MatchedStr);
if y1 > y2 then
begin
fc := fc + str2;
delete(F1, 2, lg1);
delete(F2, 2, lg2);
unification(F1, F2, S1, S2, L);
end
else
begin
fc := fc + str2;
delete(F1, 2, lg1);
delete(F2, 2, lg2);
unification(F1, F2, S1, S2, L);
end;
end
else
begin //1 символ 2 формулы - функтор?
DC1.MatchPattern := 'f\d+\((?>[^()]+)\)';
DC1.SetSubjectStr(F2);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin
str2 := DC1.MatchedStr;
lg2 := DC1.MatchedStrLength;
fc := fc + str2;
delete(F1, 2, lg1);
delete(F2, 2, lg2);
unification(F1, F2, S1, S2, L);
end
else
begin //1 символ 2 формулы - индивидная переменная?
DC1.MatchPattern := 'y\d+|x\d+';
DC1.SetSubjectStr(F2);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin //Индивидная переменная переменная связана квантором?
str2 := DC1.MatchedStr;
lg2 := DC1.MatchedStrLength;
DC1.MatchPattern := '(?<=E|A)'+str2;
DC1.SetSubjectStr(S2);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin
L.Caption := 'no3';
end
else
begin
fc := fc + str2;
delete(F1, 2, lg1);
delete(F2, 2, lg2);
unification(F1, F2, S1, S2, L);
end;
end
else
begin
L.Caption := 'no4';
end;
end;
end;
end
else
begin //1 символ 2 формулы - временная переменная?
DC1.MatchPattern := 't\d+';
DC1.SetSubjectStr(F2);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin //1 символ 1 формулы - функтор?
str2 := DC1.MatchedStr;
lg2 := DC1.MatchedStrLength;
DC1.MatchPattern := 'f\d+\((?>[^()]+)\)';
DC1.SetSubjectStr(F1);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin
str1 := DC1.MatchedStr;
lg1 := DC1.MatchedStrLength;
fc := fc + str1;
delete(F1, 2, lg1);
delete(F2, 2, lg2);
unification(F1, F2, S1, S2, L);
end
else
begin //1 символ 1 формулы - индивидная переменная?
DC1.MatchPattern := 'y\d+ | x\d+';
DC1.SetSubjectStr(F1);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin //Индивидная переменная переменная связана квантором?
str1 := DC1.MatchedStr;
lg1 := DC1.MatchedStrLength;
DC1.MatchPattern := '(?<=E|A)'+str1;
DC1.SetSubjectStr(S1);
DC1.Match(1);
if DC1.SubStrCount > 0 then
begin
L.Caption := 'no5';
end
else
begin
fc := fc + str1;
delete(F1, 2, lg1);
delete(F2, 2, lg2);
unification(F1, F2, S1, S2, L);
end;
end
else
begin
L.Caption := 'no6';
end;
end;
end
else
begin
L.Caption := 'no7';
end;
end;
end;
end;
end;
end;
Amido (2005-08-01 17:16:00) [1]Ого какая... еще и с рекурсией... Отладчик, отладчик + один сплошной брейкпойнт =]
Digitman (2005-08-01 13:08:00) [2]что говорит встр.отладчик ?
Lexa (2005-08-01 07:08:00) [3]Да, забыл уточнить: процедура сравнивает 2 формулы на предмет их подобия. Например формулы
Ex1Ay1(t1,x2)и
Ex1Ay1(y3,x2)побобны.
Временная переменная t1конкретизируется индивидной - y3