Скачиваний:
26
Добавлен:
02.05.2014
Размер:
45.13 Кб
Скачать
unit Uni;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, ComCtrls;

type
TAutoState = (AUTO_SD1,AUTO_SD2, AUTO_SD_L,AUTO_SD_PR,AUTO_G,AUTO_OR,AUTO_F,AUTO_F1,AUTO_NOT,
AUTO_D,AUTO_D1,AUTO_AND,AUTO_PL,AUTO_MIN,AUTO_I,AUTO_I1,AUTO_I2,AUTO_I3,AUTO_BEGIN,
AUTO_J,AUTO_J1,AUTO_END,AUTO_TO,
AUTO_K,AUTO_K1,AUTO_K2,AUTO_K3,AUTO_K4,AUTO_DOWNTO,
AUTO_L,AUTO_L1,AUTO_FOR,
AUTO_M,AUTO_DO,
AUTO_BIN, AUTO_ZAK,
AUTO_OTKR,AUTO_OTKR1,AUTO_ZAKR,AUTO_ZAKR1,
AUTO_PROG,AUTO_PROG1,AUTO_PROG2,AUTO_PROG3,
AUTO_H,AUTO_A,AUTO_IF,AUTO_B,AUTO_B1,AUTO_B2,AUTO_THEN,AUTO_C,AUTO_C1,
AUTO_C2,AUTO_ELSE,AUTO_RAZD,AUTO_OS,AUTO_RC,AUTO_p,AUTO_PRISV,AUTO_ID,AUTO_E,AUTO_S);

TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label13: TLabel;
Label6: TLabel;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
StringGrid2: TStringGrid;
Memo2: TMemo;
Edit1: TEdit;
Button4: TButton;
Memo3: TMemo;
Button5: TButton;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
StringGrid1: TStringGrid;
Edit6: TEdit;
Edit7: TEdit;
Memo4: TMemo;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Button6: TButton;
Button7: TButton;
Edit11: TEdit;
Edit13: TEdit;
StringGrid3: TStringGrid;
Edit5: TEdit;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
Label12: TLabel;
Label14: TLabel;
Button9: TButton;
Button8: TButton;
Memo5: TMemo;
Memo6: TMemo;
StringGrid4: TStringGrid;
Label15: TLabel;
Button10: TButton;
Button3: TButton;
StringGrid5: TStringGrid;
StringGrid6: TStringGrid;
Memo7: TMemo;
Label16: TLabel;
Memo8: TMemo;
TreeView1: TTreeView;
Button11: TButton;
Edit12: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);


private
{ Private declarations }
public
ukazatel,vssrav,knop,vssrav1,knop1:integer;
srsrav,srsrav1: real;
inputString:TStringList;
end;
const
PredMatrix:array [1..27,1..27] of char=
( {pr end. ; if then els beg end for to do dow := or and < > = not - + >> << a ( ) !}
{prog} (' ','=','<','<',' ',' ','<',' ','<',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{end.} (' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<'),
{;} (' ','>','>','<',' ',' ','<','>','<',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{if} (' ',' ',' ',' ','=',' ',' ',' ',' ',' ',' ',' ',' ','<','<','<','<','<','<','<','<',' ',' ','<','<',' ',' '),
{then} (' ','>','>','<',' ','=','<','>','<','>',' ','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{else} (' ','>','>','<',' ','>','<','>','<','>',' ','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{begin}(' ',' ','<','<',' ',' ','<','=','<',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{end} (' ','>','>',' ',' ','>',' ','>',' ','>',' ','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '),
{for} (' ',' ',' ','<',' ',' ','<',' ','<','=',' ','=',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{to} (' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','=',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{do }(' ','>','>','<',' ','>','<','>','<','>',' ','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{dow} (' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','=',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' '),
{:=} (' ','>','>',' ',' ','>',' ','>',' ','>',' ','>',' ',' ',' ',' ',' ',' ',' ','<','<',' ',' ','<','<','=',' '),
{or} (' ',' ',' ',' ','>',' ',' ',' ',' ',' ',' ',' ',' ','>','<','<','<','<','<','<','<',' ',' ','<','<','>',' '),
{and} (' ',' ',' ',' ','>',' ',' ',' ',' ',' ',' ',' ',' ','>','<','<','<','<','<','<','<',' ',' ','<','<','>',' '),
{< } (' ',' ',' ',' ','>',' ',' ',' ',' ',' ',' ',' ',' ','>','<',' ',' ',' ',' ','<','<',' ',' ','<','<','>',' '),
{>} (' ',' ',' ',' ','>',' ',' ',' ',' ',' ',' ',' ',' ','>','<',' ',' ',' ',' ','<','<',' ',' ','<','<','>',' '),
{=} (' ',' ',' ',' ','>',' ',' ',' ',' ',' ',' ',' ',' ','>','<',' ',' ',' ',' ','<','<',' ',' ','<','<','>',' '),
{not} (' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','=',' ',' '),
{-} (' ','>','>',' ','>','>',' ','>',' ','>',' ','>',' ','>','>','>','>','>','>','>','>',' ',' ','<','<','>',' '),
{+} (' ','>','>',' ','>','>',' ','>',' ','>',' ','>',' ','>','>','>','>','>','>','>','>',' ',' ','<','<','>',' '),
{>>} (' ','>','>',' ','>','>',' ','>',' ','>',' ','>',' ','>','>','>','>','>','>','>','>',' ',' ','<','<','>',' '),
{<<} (' ','>','>',' ','>','>',' ','>',' ','>',' ','>',' ','>','>','>','>','>','>','>','>',' ',' ','<','<','>',' '),
{a} (' ','>','>',' ','>','>',' ','>',' ','>','>','>','=','>','>','>','>','>','>','>','>','=','=',' ',' ','>',' '),
{(} (' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','=','<','<','<','<','<','<','<','<',' ',' ','<','>','=',' '),
{)} (' ','>','>',' ',' ','>',' ','>',' ','>','>','>',' ','>','>','>','>','>','>','>','>',' ',' ',' ',' ','>',' '),
{!} ('<',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '));
{Iienaiea i?aaee a?aiiaoeee}
grammar:array [1..26] of string=
('progEend.','E','E;E','E;','ifEthenEelseE','ifEthenE','beginEend','forEtoEdoE','forEdowntoEdoE','a:=E',
'EorE','E','EandE','E','E<E','E>E','E=E','not(E)','E','E-E','E+E','a>>E','a<<E','E','a','(E)');
term:array [1..27] of string=
('prog','end.',';','if','then','else','begin','end','for','to','do','downto',':=','or','and','<','>','=','not','-','+','>>','<<','a','(',')','!');
notterm:array [1..26] of char=
('E','E','E','E','E','E','E','E','E','E','E','E',
'E','E','E','E','E','E','E','E','E','E','E','E','E','E');
CanonO:array [1..26,1..6] of string=
(('prog','E','end.','','',''),
('E','','','','',''),
('E',';','E','','',''),
('E',';','','','',''),
('if','E','then','E','else','E'),
('if','E','then','E','',''),
('begin','E','end','','',''),
('for','E','to','E','do',''),
('for','E','downto','E','do',''),
('a',':=','E','','',''),
('E','or','E','','',''),
('E','','','','',''),
('E','and','E','','',''),
('E','','','','',''),
('E','<','E','','',''),
('E','>','E','','',''),
('E','=','E','','',''),
('not','(','E',')','',''),
('E','','','','',''),
('E','-','E','','',''),
('E','+','E','','',''),
('a','>>','E','','',''),
('a','<<','E','','',''),
('E','','','','',''),
('a','','','','',''),
('(','E',')','','',''));
var
Form1: TForm1;

implementation
function IndMatrix(SymS:String):integer;
var iq:integer;
begin
indMatrix:=0;
if term[1]=SymS then IndMatrix:=1;
for iq:=1 to 27 do
if term[iq]=SymS then IndMatrix:=iq;
end;


function inArray(myS:String;A:Array of string;N:integer):boolean;
var i:integer;
begin
inArray:=False;
if myS='prog' then inArray:=true;
for i:=1 to N do
if myS=A[i] then begin inArray:=true end;
end;


function NomRul(myS:String):integer;
var i:integer;
begin
NomRul:=0;
if (myS=grammar[1])then NomRul:=1;
for i:=1 to 26 do
if grammar[i]=myS then NomRul:=i;
end;


function findnt(myS:String):string;
begin
findnt:='';
findnt:=notterm[nomRul(myS)]
end;

{===============================================================================}
{var
Form1: TForm1; }

{implementation}

{$R *.DFM}
const hash_max = ord('я')+ord('я');
{hash_min = ord('A')+ord('A');}
function Hesh(St:string):integer;
var dlina:integer;
begin
dlina:=length(St);
if dlina=0 then Result:=0 else
begin
if dlina>=3 then
begin
Result:=ord(St[(dlina+1)div 2])+ord(St[dlina]);
end
else begin
Result:=ord(St[1]);
end;

end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.execute then
Memo1.lines.loadFromFile(OpenDialog1.FileName)
end;

procedure TForm1.Button2Click(Sender: TObject);
var i,k,dlina,hash,j,kol:integer;
stroka:string;
label 1,2;
begin
j:=0;
k:=1;
kol:=0;
ukazatel:=0;
dlina:=memo1.Lines.Count;
if dlina<>0 then
begin
for i:=0 to dlina-1 do
begin
stroka:=memo1.Lines[i];
hash:=Hesh(stroka);
if (StringGrid2.cells[1,hash])='' then
begin
StringGrid2.cells[1,hash]:=IntToStr(hash);
StringGrid2.cells[2,hash]:=stroka;

end
else
begin
1: if (StringGrid2.cells[2,hash])=stroka then
begin
// kol:=kol+1;
memo2.Lines[j]:='Удален повтор '+stroka;
j:=j+1;
ukazatel:=ukazatel+1;
goto 2;
end
else
begin
kol:=kol+1;
hash:=(Hesh(stroka)+k) mod 509;
if (StringGrid2.cells[1,hash])='' then
begin
StringGrid2.cells[1,hash]:=IntToStr(hash);
StringGrid2.cells[2,hash]:=stroka;

end
else
begin
k:=k+1;
goto 1;
end;
end;
end;
2: end;
end;
Edit2.Text:=IntToStr(kol);


end;

procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
srsrav:=0;
knop:=0;
vssrav:=0;
srsrav1:=0;
knop1:=0;
vssrav1:=0;
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
Edit6.Text:='';
Edit7.Text:='';
Edit8.Text:='';
Edit9.Text:='';
Edit10.Text:='';
Edit11.Text:='';
Edit13.Text:='';
memo1.Text:='';
memo2.Text:='';
memo3.Text:='';
memo4.Text:='';
memo8.Text:='';
StringGrid2.Cells[0,0]:='Номер';
StringGrid2.Cells[1,0]:='ХФ';
StringGrid2.Cells[2,0]:='Иден-р';
StringGrid1.Cells[0,0]:='Номер';
StringGrid1.Cells[1,0]:='Иден-р';
StringGrid3.Cells[0,0]:='Номер';
StringGrid3.Cells[1,0]:='ХФ';
StringGrid3.Cells[2,0]:='Иден-р';
StringGrid3.Cells[3,0]:='Ссылки';
StringGrid5.Cells[0,0]:='Номер';
StringGrid5.Cells[1,0]:='Иден-р';
StringGrid6.Cells[0,0]:='Номер';
StringGrid6.Cells[1,0]:='ХФ';
StringGrid6.Cells[2,0]:='Иден-р';
StringGrid6.Cells[3,0]:='Ссылки';
for i:=1 to 510 do StringGrid2.Cells[0,i]:=IntToStr(i);
for i:=1 to 510 do StringGrid1.Cells[0,i]:=IntToStr(i);
for i:=1 to 510 do StringGrid5.Cells[0,i]:=IntToStr(i);
for i:=1 to 510 do StringGrid6.Cells[0,i]:=IntToStr(i);
Memo5.Text:='';
Memo6.Text:='';
StringGrid4.Cells[0,0]:='№';
StringGrid4.Cells[1,0]:='Значение';
StringGrid4.Cells[2,0]:='Лексема';
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Button4Click(Sender: TObject);
var k,hash,dlina,i,srav,j,si: integer;
stroka: string;

label met1,met2;
begin
knop:=knop+1;
memo3.Lines[0]:='';
k:=1;
srav:=0;
stroka:=Edit1.Text;
if stroka='' then
begin
memo3.Lines[0]:='Поле пусто!';
goto met1;
end;
dlina:=memo1.Lines.Count;
hash:=Hesh(stroka);
for i:=1 to 510 do
begin
srav:=srav+1;

if StringGrid2.Cells[1,hash]=IntToStr(hash) then
begin
if stroka=StringGrid2.Cells[2,hash] then
begin
memo3.Lines[0]:='Иден-р '+stroka+' найден! Его номер '+ IntToStr(hash);
goto met1;
end
else
begin
for j:=1 to 510 do
begin
srav:=srav+1;
hash:=(Hesh(stroka)+k) mod 509;
k:=k+1;
if StringGrid2.Cells[1,hash]=IntToStr(hash) then
begin
if stroka=StringGrid2.Cells[2,hash] then
begin
memo3.Lines[0]:='Иден-р '+stroka+' найден! Его номер '+ IntToStr(hash);
goto met1;
end;
end
else memo3.Lines[0]:='Иден-р '+stroka+' не найден!';
end;
end;
end
else begin
memo3.Lines[0]:='Иден-р '+stroka+' не найден!';
goto met1; end;
end;
met1: Edit3.Text:=inttostr(hash);
Edit4.Text:=inttostr(srav);

dlina:=memo1.Lines.Count;
for si:=0 to dlina-1 do
begin
k:=1;
srav:=0;
stroka:=memo1.Lines[si];
hash:=Hesh(stroka);
for i:=1 to 510 do
begin
srav:=srav+1;
if StringGrid2.Cells[1,hash]=IntToStr(hash) then
begin
if stroka=StringGrid2.Cells[2,hash] then
begin
goto met2;
end
else
begin
for j:=1 to 510 do
begin
srav:=srav+1;
hash:=(Hesh(stroka)+k) mod 509;
k:=k+1;
if StringGrid2.Cells[1,hash]=IntToStr(hash) then
begin
if stroka=StringGrid2.Cells[2,hash] then
begin
goto met2;
end;
end;
end;
end;
end
else begin
goto met2; end;
end;
met2: vssrav:=vssrav+srav;
end;
srsrav:=vssrav/dlina;
Edit11.Text:=inttostr(vssrav);
Edit9.Text:=floattostr(srsrav);


end;

procedure TForm1.Button5Click(Sender: TObject);
var i: integer;
begin
for i:=1 to 510 do StringGrid2.Cells[1,i]:='';
for i:=1 to 510 do StringGrid2.Cells[2,i]:='';
for i:=1 to 510 do StringGrid1.Cells[1,i]:='';
for i:=1 to 510 do StringGrid3.Cells[1,i]:='';
for i:=1 to 510 do StringGrid3.Cells[2,i]:='';
for i:=1 to 510 do StringGrid3.Cells[3,i]:='';
memo1.Text:='';
memo2.Text:='';
memo3.Text:='';
memo4.Text:='';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
Edit6.Text:='';
Edit7.Text:='';
Edit8.Text:='';
Edit9.Text:='';
Edit10.Text:='';
Edit11.Text:='';
Edit13.Text:='';
end;

procedure TForm1.Button6Click(Sender: TObject);
var i,dlina,hash,useukazat,kol,j:integer;
stroka:string;
label 1,2;
begin
kol:=0;
ukazatel:=1;
j:=0;
dlina:=memo1.Lines.Count;
if dlina<>0 then
begin
StringGrid3.RowCount:=dlina+1;
for i:=1 to dlina do
begin
StringGrid3.Cells[0,i]:=IntToStr(i);
end;
for i:=0 to dlina-1 do
begin
stroka:=memo1.Lines[i];
hash:=Hesh(stroka);
if StringGrid1.cells[1,hash]='' then
begin
StringGrid1.cells[1,hash]:=IntToStr(ukazatel);
StringGrid3.cells[1,ukazatel]:=IntToStr(hash);
StringGrid3.cells[2,ukazatel]:=stroka;
ukazatel:=ukazatel+1;
goto 1;
end;
if StringGrid1.cells[1,hash]<>'' then
begin
useukazat:=StrToInt(StringGrid1.cells[1,hash]);
2: if stroka=StringGrid3.Cells[2,useukazat] then
begin
memo2.Lines[j]:='Удален повторяющийся идентификатор '+stroka;
j:=j+1;
end
else if StringGrid3.cells[3,useukazat]='' then
begin
StringGrid3.cells[3,useukazat]:=IntToStr(ukazatel);
StringGrid3.cells[1,ukazatel]:=IntToStr(hash);
StringGrid3.cells[2,ukazatel]:=stroka;
ukazatel:=ukazatel+1;
inc(kol);
goto 1;
end;
if StringGrid3.cells[3,useukazat]<>'' then
begin
useukazat:=StrToInt(StringGrid3.cells[3,useukazat]);
goto 2;
end;
end;
1: end;
end;
Edit5.Text:=IntToStr(kol);
StringGrid3.RowCount:=ukazatel+1;
end;


procedure TForm1.Button7Click(Sender: TObject);
var useukaz,hash,srav,dlina,si,kol,i,j: integer;
stroka: string;
label met1, met2, met3, met4;
begin
srav:=0;
kol:=0;
memo4.Lines[0]:='';
stroka:=Edit8.Text;
if stroka='' then
begin
memo4.Lines[0]:='Поле пусто!';
goto met1;
end;
hash:=Hesh(stroka);
if StringGrid1.Cells[1,hash]=''
then memo4.Lines[0]:='Идентификатор '+stroka+' не найден!' else
begin
useukaz:=StrToInt(StringGrid1.Cells[1,hash]);
met3: srav:=srav+1;
if StringGrid3.Cells[2,useukaz]=stroka then
begin
memo4.Lines[0]:='Идентификатор '+stroka+' найден! Его номер '+ IntToStr(useukaz);
goto met1;
end ;
if stroka<>StringGrid3.Cells[2,useukaz] then
begin
useukaz:=StrToInt(StringGrid3.Cells[3,useukaz]);
kol:=kol+1;
goto met3;
end;

end;
met1:
Edit6.Text:=inttostr(hash) ;
Edit7.Text:=inttostr(srav) ;
//Edit5.Text:=inttostr(kol) ;
// end;


vssrav:=0;
dlina:=memo1.Lines.Count;
for si:=0 to dlina-1 do
begin
srav:=0;
stroka:=memo1.Lines[si];
hash:=Hesh(stroka);

useukaz:=StrToInt(StringGrid1.Cells[1,hash]);
// showmessage(inttostr(hash));
met2: srav:=srav+1;
if StringGrid3.Cells[2,useukaz]=stroka then goto met4;

if stroka<>StringGrid3.Cells[2,useukaz] then
begin
useukaz:=StrToInt(StringGrid3.Cells[3,useukaz]);
goto met2;
end;








met4: vssrav:=vssrav+srav;
end;
srsrav:=vssrav/dlina;
Edit13.Text:=inttostr(vssrav);
Edit10.Text:=floattostr(srsrav);
vssrav:=0;
srsrav:=0;
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
if OpenDialog1.Execute then Memo5.Lines.LoadFromFile(OpenDialog1.FileName) ;
end;

procedure TForm1.Button9Click(Sender: TObject);
Const N1=26;
N2=21;
N3=26;
N4=5;
var ind,pos,dl,i,j,i1,fl,fll,zn:integer;
st,str,sInput:string;
iState:TAutoState;
dlina,hash,useukazat,kol,f:integer;
stroka:string;
CepofV1:array [1..100]of integer;
p,stek,d:TStringList;
o1,o2,o3,o4,o5,o6,pr:string;
MyTreeNode:TTreeNode;
nodeTree: TTreeNode;
label 1,2;
begin
fll:=0;

inputString:=TStringList.Create;
inputString.Sorted:=False;

for i:=0 to 2 do
for j:=1 to 999 do
StringGrid4.Cells[i,j]:='';
j:=Memo5.Lines.Count;
ind:=1;
pos:=1;
for i:=1 to j do
begin
str:='';
sInput:=Memo5.Lines[i-1];
sInput:=sInput+' ';
dl:=Length(sInput);
iState:=AUTO_H;
fl:=0;
zn:=0;
for j:=1 to dl do
begin
st:=sInput[j];
case iState of
AUTO_H:
case sInput[j] of
'b': begin iState:=AUTO_I;str:=str+st; end;
'(': begin iState:=AUTO_OTKR1;str:=str+st; end;
')': begin iState:=AUTO_ZAK;str:=str+st; end;
// '*': begin iState:=AUTO_ZAKR1;str:=str+st; end;
'p': begin iState:=AUTO_PROG1;str:=str+st;end;
'0': begin iState:=AUTO_BIN;str:=str+st;end;
'f': begin iState:=AUTO_L;str:=str+st; end;
'd': begin iState:=AUTO_K;str:=str+st; end;
'+': begin iState:=AUTO_PL;str:=str+st; end;
'-': begin iState:=AUTO_MIN;str:=str+st; end;
'>': begin iState:=AUTO_SD1;str:=str+st; end;
'<': begin iState:=AUTO_SD2;str:=str+st; end;
'a': begin iState:=AUTO_D;str:=str+st; end;
'o': begin iState:=AUTO_G;str:=str+st; end;
'n': begin iState:=AUTO_F;str:=str+st; end;
'i': begin iState:=AUTO_A;str:=str+st; end;
't': begin iState:=AUTO_B;str:=str+st; end;
'e': begin iState:=AUTO_C;str:=str+st; end;
'=': begin iState:=AUTO_OS;str:=str+st; end;
';': begin iState:=AUTO_RAZD;str:=str+st; end;
' ': begin iState:=AUTO_H;str:='';end;
':': begin iState:=AUTO_P;str:=str+st; end;
'c','g'..'h','j'..'m','q','s','u'..'z','1'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_ZAK:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=61; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_OTKR1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=60; end;
'*':begin iState:=AUTO_OTKR; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_OTKR:
case sInput[j] of
'*':begin iState:=AUTO_ZAKR1;end;
else begin iState:= AUTO_OTKR; end;
end;

AUTO_ZAKR1:
case sInput[j] of
')':begin iState:=AUTO_H; fll:=0; end;
else begin iState:= AUTO_OTKR; end;
end;

AUTO_ZAKR:
case sInput[j] of
' ':begin iState:=AUTO_H;fl:=1;zn:=41; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;


AUTO_PROG1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'r':begin iState:=AUTO_PROG2; str:=str+st; end;
'a'..'q','s'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_PROG2:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'o':begin iState:=AUTO_PROG3; str:=str+st; end;
'a'..'n','p'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_PROG3:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
'g':begin iState:=AUTO_PROG; str:=str+st; end;
'a'..'f','h'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_PROG:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_BIN:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=30;end;
'1','0':begin iState:=AUTO_BIN;str:=str+st;end;
'a'..'z','2'..'9':begin iState:=AUTO_ID;str:=str+st;end;
end;

AUTO_L:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'o':begin iState:=AUTO_L1; str:=str+st; end;
'a'..'n','p'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_L1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'r':begin iState:=AUTO_FOR; str:=str+st; end;
'a'..'q','s'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_FOR:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_K:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'o':begin iState:=AUTO_K1; str:=str+st; end;
'a'..'n','p'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_K1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
'w':begin iState:=AUTO_K2; str:=str+st; end;
'a'..'v','x'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_K2:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'n':begin iState:=AUTO_K3; str:=str+st; end;
'a'..'m','o'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_K3:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
't':begin iState:=AUTO_K4; str:=str+st; end;
'a'..'s','u'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_K4:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'o':begin iState:=AUTO_DOWNTO; str:=str+st; end;
'a'..'n','p'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_DOWNTO:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_PL:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=22;end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_MIN:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=23;end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_SD1:
case sInput[j] of
'>':begin iState:=AUTO_SD_PR; str:=str+st; end;
' ': begin iState:=AUTO_H;fl:=1;zn:=7;end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_SD2:
case sInput[j] of
'<':begin iState:=AUTO_SD_L; str:=str+st; end;
' ': begin iState:=AUTO_H;fl:=1;zn:=7;end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_SD_PR:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=20;end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_SD_L:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=21;end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_D:
case sInput[j] of
'n':begin iState:=AUTO_D1; str:=str+st; end;
'>','<','=',';',':':begin iState:= AUTO_E;str:=str+st; end;
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_D1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'd':begin iState:=AUTO_AND; str:=str+st; end;
'a'..'c','e'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_AND:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=4;end;
'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_G:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'r':begin iState:=AUTO_OR; str:=str+st; end;
'a'..'q','s'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;
AUTO_OR:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=4;end;
'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_F:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'o':begin iState:=AUTO_F1; str:=str+st; end;
'a'..'n','p'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_F1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
't':begin iState:=AUTO_NOT; str:=str+st; end;
'a'..'s','u'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;

AUTO_NOT:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=4;end;
'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:= AUTO_E;str:=str+st; end;
end;


AUTO_ID:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=2;end;
// ':',';','=','<','>':

'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E; str:=str+st; end;
end;

AUTO_P:
case sInput[j] of
'=': begin iState:=AUTO_PRISV;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_PRISV:
case sInput[j] of
' ':begin iState:=AUTO_H;fl:=1;zn:=3;end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_A:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'f': begin iState:=AUTO_IF;str:=str+st; end;
'>','<','=',';',':': begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_IF:
case sInput[j] of
' ': begin iState:=AUTO_H;fl:=1;zn:=4; end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_B:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'h': begin iState:=AUTO_B1;str:=str+st; end;
'o': begin iState:=AUTO_TO;str:=str+st; end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_B1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'e':begin iState:=AUTO_B2;str:=str+st; end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_B2:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'n':begin iState:=AUTO_THEN;str:=str+st; end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_THEN:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_C:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'l':begin iState:=AUTO_C1;str:=str+st; end;
'n':begin iState:=AUTO_J;str:=str+st;end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_C1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
's':begin iState:=AUTO_C2;str:=str+st; end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_C2:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'e':begin iState:=AUTO_ELSE;str:=str+st; end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;

AUTO_ELSE:
case sInput[j] of
' ':begin iState:=AUTO_H;fl:=1;zn:=6;end;
'>','<','=',';',':':begin iState:=AUTO_E;str:=str+st; end;
else begin iState:=AUTO_ID;str:=str+st; end;
end;


/////
AUTO_OS:
case sInput[j] of
' ':begin iState:=AUTO_H;fl:=1;zn:=7; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_RAZD:
case sInput[j] of
' ':begin iState:=AUTO_H;fl:=1;zn:=8; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_I:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'e':begin iState:=AUTO_I1;str:=str+st; end;
'a'..'d','f'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_I1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'g':begin iState:=AUTO_I2;str:=str+st; end;
'a'..'f','h'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_I2:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'i':begin iState:=AUTO_I3;str:=str+st; end;
'a'..'h','j'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_I3:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'n':begin iState:=AUTO_BEGIN;str:=str+st; end;
'a'..'m','o'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_BEGIN:
case sInput[j] of
' ':begin iState:=AUTO_H;fl:=1;zn:=4; end;
'a'..'f','h'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_J1:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_J:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=2;end;
'd':begin iState:=AUTO_END;str:=str+st;end;
'a'..'c','e'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_END:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
'.':begin iState:=AUTO_J1; str:=str+st;end;
'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_TO:
case sInput[j] of
' ':begin iState:=AUTO_H; fl:=1;zn:=4;end;
'a'..'z','0'..'9':begin iState:=AUTO_ID;str:=str+st; end;
else begin iState:=AUTO_E;str:=str+st; end;
end;

AUTO_E: begin
if sInput[j]<>' 'then
begin
iState:=AUTO_E;
str:=str+st;
end
else
begin
iState:=AUTO_H;
Memo6.Lines.Append(str);
str:='';
end;


end;
end;
if fll=0 then if fl=1 then
begin
StringGrid4.Cells[0,ind]:=IntToStr(ind);
StringGrid4.Cells[1,ind]:=str;
case zn of
1: begin StringGrid4.Cells[2,ind]:='Римская цифра'; inputString.Add(str); end;
2:begin StringGrid4.Cells[2,ind]:='Идентификатор';inputString.Add('a'); end;
3:begin StringGrid4.Cells[2,ind]:='Оператор присваивания';inputString.Add(':='); end;
4:begin StringGrid4.Cells[2,ind]:='Ключевое слово';inputString.Add(str); end;
7:begin StringGrid4.Cells[2,ind]:='Оператор сравнения';inputString.Add(str); end;
8:begin StringGrid4.Cells[2,ind]:='Разделитель'; inputString.Add(';'); end;
20:begin StringGrid4.Cells[2,ind]:='Сдвиг вправо';inputString.Add('>>'); end;
21:begin StringGrid4.Cells[2,ind]:='Сдвиг влево';inputString.Add('<<');end;
23:begin StringGrid4.Cells[2,ind]:='Вычетание'; inputString.Add('-');end;
22:begin StringGrid4.Cells[2,ind]:='Сложение';inputString.Add('+'); end;
30:begin StringGrid4.Cells[2,ind]:='Бинарная константа';inputString.Add(str); end;
40:begin StringGrid4.Cells[2,ind]:='Начало комментария';inputString.Add(str); end;
41:begin StringGrid4.Cells[2,ind]:='Конец комментария';inputString.Add(str);end;
60:begin StringGrid4.Cells[2,ind]:='Откр. скобка';inputString.Add('(');end;
61:begin StringGrid4.Cells[2,ind]:='Закр. скобка';inputString.Add(')');end;
end;
// showmessage(str);
str:='';
ind:=ind+1;
fl:=0;
end;
end;
end;

// Edit2.Text:=IntToStr(ind-1);


Begin // добавление в ХТ

for i:=1 to 510 do
begin
if stringgrid4.Cells[2,i]='Идентификатор' then
memo8.Lines.Append(stringgrid4.Cells[1,i]);
end;
kol:=0;
ukazatel:=1;
j:=0;
dlina:=memo8.Lines.Count;
if dlina<>0 then
begin
// StringGrid3.RowCount:=dlina+1;
for i:=1 to dlina do
begin
StringGrid6.Cells[0,i]:=IntToStr(i);
end;
for i:=0 to dlina-1 do
begin
stroka:=memo8.Lines[i];
hash:=Hesh(stroka);
if StringGrid5.cells[1,hash]='' then
begin
StringGrid5.cells[1,hash]:=IntToStr(ukazatel);
StringGrid6.cells[1,ukazatel]:=IntToStr(hash);
StringGrid6.cells[2,ukazatel]:=stroka;
ukazatel:=ukazatel+1;
goto 1;
end;
if StringGrid5.cells[1,hash]<>'' then
begin
useukazat:=StrToInt(StringGrid5.cells[1,hash]);
2: if stroka=StringGrid6.Cells[2,useukazat] then
begin
memo7.Lines[j]:='Удален повторяющийся идентификатор '+stroka;
j:=j+1;
end
else if StringGrid6.cells[3,useukazat]='' then
begin
StringGrid6.cells[3,useukazat]:=IntToStr(ukazatel);
StringGrid6.cells[1,ukazatel]:=IntToStr(hash);
StringGrid6.cells[2,ukazatel]:=stroka;
ukazatel:=ukazatel+1;
inc(kol);
goto 1;
end;
if StringGrid6.cells[3,useukazat]<>'' then
begin
useukazat:=StrToInt(StringGrid6.cells[3,useukazat]);
goto 2;
end;
end;
1: end;
end;
Edit5.Text:=IntToStr(kol);




end;//Добавление в ХТ
end;






procedure TForm1.Button10Click(Sender: TObject);
var i:integer;
begin
for i:=1 to 510 do StringGrid4.Cells[1,i]:='';
for i:=1 to 510 do StringGrid4.Cells[2,i]:='';
for i:=1 to 510 do StringGrid5.Cells[1,i]:='';
for i:=1 to 510 do StringGrid5.Cells[2,i]:='';
for i:=1 to 510 do StringGrid6.Cells[1,i]:='';
for i:=1 to 510 do StringGrid6.Cells[2,i]:='';
for i:=1 to 510 do StringGrid6.Cells[3,i]:='';
memo5.Text:='';
memo6.Text:='';
memo7.Text:='';
memo8.Text:='';
end;

{=============================================================================}












procedure TForm1.Button11Click(Sender: TObject);
label Myend,zap,tree;

var SymbStack:TStringList;{входная строка и стэк соответственно}
i,j,verh,k,vetv,n,m:integer;
gamma,MyinS,syms,tek,cep:String;
mycase:char;
CepofV:array [1..100]of integer;
begin

for i:=0 to inputString.Count-1 do MyinS:=MyinS+InputString[i];
{Edit2.Text:=MyinS;}

if inputString.Count=0 then
begin
ShowMessage('Таблица лексем или исходный файл не загружены');
exit
end;
inputString.Add('!');
{Объявляем стэк}
SymbStack:=TStringList.Create;
SymbStack.Sorted:=False;
SymbStack.Add('!');
{SymbStack.Add(inputString[0]);
{inputString.Delete(0); }
i:=0;
k:=0;
cep:='';
while i<=inputString.Count-1 do
begin
verh:=SymbStack.Count-1;
syms:=SymbStack[verh];
while (not(inArray(SymbStack[verh],term,27))) do verh:=verh-1;
if (SymbStack[verh]='!') and (inputString[i]='!') then goto MyEnd;
//ShowMessage (inputString[i]);
mycase:=PredMatrix[IndMatrix(SymbStack[verh]),IndMatrix(inputString[i])];
//ShowMessage (inttostr(i));
if ((mycase='<')or(mycase='='))then
begin {сдвиг}
SymbStack.Add(inputString[i]);
i:=i+1;
end
else
if (mycase='>')
then
begin {свертка}
gamma:='';
tek:='';
for j:=SymbStack.Count-1 downto 0 do
if not(inArray(SymbStack[j],term,27)) then
begin
gamma:=SymbStack[j]+gamma;
SymbStack.Delete(j)
end
else
if (inArray(SymbStack[j],term,27))and(tek='') then
begin
tek:=SymbStack[j];
gamma:=SymbStack[j]+gamma;
SymbStack.Delete(j)
end
else
if predMatrix[Indmatrix(SymbStack[j]),IndMatrix(tek)]='=' then
begin
tek:=SymbStack[j];
gamma:=SymbStack[j]+gamma;
SymbStack.Delete(j)
end
else break;



if findnt(gamma)<>''
then
begin
SymbStack.Add(findnt(gamma));
k:=k+1;
CepofV[k]:=NomRul(gamma);
// ShowMessage('Цепочка '+gamma+' заменяется на '+findnt(gamma)+' по правилу '+inttostr(Nomrul(gamma)));
cep:=inttostr(CepofV[k])+' '+cep;
end
else
begin {ошибка}
ShowMessage('Ошибка! Цепочка '+gamma+' недопустима');
goto tree
end;
end;
if mycase=' ' then
begin {ошибка}
ShowMessage('Ошибка! Символы '+Symbstack[verh]+' и '+InputString[i]+' не могут следовать друг за другом');
goto tree;
end;
end;
Myend:Edit12.Text:=cep;
{вывод дерева}
n:=k;
with TreeView1 do
begin
Items.Add(Nil,'E');
vetv:=0;
for k:=n downto 1 do begin
m:=Items.Count;
if k<n then
for i:=m-1 downto 0 do
if Items[i].Text=notterm[CepofV[k]] then
if Items[i].HasChildren=False then
begin
vetv:=i;
goto zap
end;
zap: for i:=1 to 6 do
if CanonO[CepofV[k],i]<>'' then
Items.AddChild(Items[vetv],CanonO[CepofV[k],i])
end;
FullExpand

end;
tree:InputString.Destroy;
SymbStack.Destroy;
end;


end.
Соседние файлы в папке Берта