Конструирование транслятора для модельного языка

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование

tringGrid4.Cells[0,j]:='';.StringGrid4.Cells[1,j]:='';;:=['A'..'z'];:=['0'..'9'];:=[' ','.',',',';',':','=','(',')','+','-','*','>',''];i:=0 to Form1.memo2.lines.count-1 do:=Form1.Memo2.Lines[i]+' ';:=1;n<=length(stroka) dostroka[n] in bykva then:=stroka[n];(n);(stroka[n] in ogran1)=false do:=str+stroka[n];(n);;:=false;j:=0 to Form1.StringGrid1.Cols[0].Count-1 doForm1.StringGrid1.Cells[1,j]=str then:=StrToInt(Form1.StringGrid1.Cells[0,j]);:=1;:=i+1;.Memo1.Lines.Add(inttostr(nlex)+' '+inttostr(ntab)+' '+inttostr(nstr));:=true;;flag=false thenj:=0 to Form1.StringGrid3.Cols[0].Count-1 doForm1.StringGrid3.Cells[1,j]=str then:=4;:=StrToInt(Form1.StringGrid3.Cells[0,j]);:=i+1;.Memo1.Lines.Add(inttostr(nlex)+' '+inttostr(ntab)+' '+inttostr(nstr));:=true;;flag=false thenj:=0 to Form1.StringGrid3.Cols[0].Count-1 doForm1.StringGrid3.Cells[0,j]='' then.StringGrid3.Cells[0,j]:=IntToStr(j+1);.StringGrid3.Cells[1,j]:=str;:=StrToInt(Form1.StringGrid3.Cells[0,j]);:=i+1;:=4;.Memo1.Lines.Add(inttostr(nlex)+' '+inttostr(ntab)+' '+inttostr(nstr));:=true;;;;

//Числаstroka[n] in Number then:=stroka[n];(n);(stroka[n] in ogran2)=false do:=str+stroka[n];(n);;(str, numVal, error);error=0 then:=false;j:=0 to Form1.StringGrid4.Cols[0].Count-1 doForm1.StringGrid4.Cells[1,j]=str then:=StrToInt(Form1.StringGrid4.Cells[0,j]);:=3;:=i+1;.Memo1.Lines.Add(inttostr(nlex)+' '+inttostr(ntab)+' '+inttostr(nstr));:=true;;flag=false thenj:=0 to Form1.StringGrid4.Cols[0].Count-1 doForm1.StringGrid4.Cells[0,j]='' then.StringGrid4.Cells[0,j]:=IntToStr(j+1);.StringGrid4.Cells[1,j]:=str;:=StrToInt(Form1.StringGrid4.Cells[0,j]);:=3;:=i+1;.Memo1.Lines.Add(inttostr(nlex)+' '+inttostr(ntab)+' '+inttostr(nstr));;;('Ошибка синтаксиса в '+IntToStr(nstr+1)+' строке: '+str);;;

//Ограничители(stroka[n] in ogran1) or (stroka[n] in ogran2) thenstroka[n]=' ' then(n);:=false;:=stroka[n];(n);stroka[n] in ogran3 then:=str+stroka[n];(n);;j:=0 to Form1.StringGrid2.RowCount-1 doForm1.StringGrid2.Cells[1,j]=str then:=StrToInt(Form1.StringGrid2.Cells[0,j]);:=2;:=i+1;.Memo1.Lines.Add(inttostr(nlex)+' '+inttostr(ntab)+' '+inttostr(nstr));;;;elsePos(stroka[n], rus)true do(gr,c);.cells[1,i]:=c;.cells[0,i]:=inttostr(i+1);.RowCount:=stringgrid2.RowCount+1;:=i+1;;(gr);;TForm1.FormCreate(Sender: TObject);.Memo1.Clear;.Memo2.clear;;

//СинтаксисTForm1.Button5Click(Sender: TObject);('fas\Project1.exe',SW_SHOW);;.

Синтаксический анализ

unit Unit1;, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,, StdCtrls, Grids;= class(TForm): TButton;: TStringGrid;Button1Click(Sender: TObject);FormCreate(Sender: TObject);

{ Private declarations }

{ Public declarations };: TForm1;:textfile;,k2,k3:string;:integer;:set of byte;

{$R *.dfm}Er(r:integer);forward;Nextsymb;:=num+1;:='';:='';:='';:=form1.stringgrid1.Cells[0,num];:=form1.stringgrid1.Cells[1,num];:=form1.stringgrid1.Cells[2,num];;Presymb;:=num-1;:='';:='';:='';:=form1.stringgrid1.Cells[0,num];:=form1.stringgrid1.Cells[1,num];:=form1.stringgrid1.Cells[2,num];;D2;forward;B;forward;Proc_P1;;;;S1;forward;B;;((k1'1')) then Er(12);;

//Nextsymb;((k1' ') do:=s3+s[i];:=i+1;;.stringgrid1.Cells[2,j]:=s3;:=j+1;.StringGrid1.RowCount:=Form1.StringGrid1.RowCount+1;;:=-1;(a5);;Er(r:integer);r of

: showmessage('нет begin в строке '+k3);

: showmessage('нет end в строке '+k3);

: showmessage('нет Integer в строке'+k3);

4: showmessage('нет идентификатора в строке'+k3);

: showmessage('необъявленный идентификатор в строке '+k3);

: showmessage('нет := в строке '+k3);

: showmessage('нет ; в строке '+k3);

: showmessage ('нет ( в строке '+k3);

: showmessage('нет )в строке '+k3);

: showmessage('необъявленный идентификаторв в строке '+k3);

: showmessage('нет While в строке '+k3);

: showmessage('нет Do в строке '+k3);

13: showmessage ('нет EndWhile в строке '+k3);

: showmessage('нет >|=|<=|= в строке '+k3);

15: showmessage('нет ; или , в строке '+k3);

: showmessage('данный идентификатор в строке '+k3+' уже объявлен');

:showmessage('успешно выполнен анализ');;

halt;;.