⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proc_func.~pas

📁 delphi编的pl0编译器
💻 ~PAS
字号:
unit Proc_Func;

interface
uses
  SysUtils;

Procedure PrintWordlist;
procedure WriteToMemo3;
procedure SaveToFile;
procedure Clear_errormark;
procedure Set_errormark;

implementation
uses Defination,Main;

procedure SaveToFile;   //将Memo1中的内容保存到C:\temporary_source_word.txt
var
  s:string;
  f:text;
begin
  chdir('C:\');
  assignfile(f,'temporary_source_word.txt');
  rewrite(f);
  s:=MainForm.Memo1.Text;
  write(f,s);
  closefile(f);
end;

Procedure PrintWordlist;       //打印单词表到文件C:\temporary_result_word.txt
var
  j:integer;
begin
  j:=1;

  chdir('C:\');
  assignfile(fout,'temporary_result_word.txt');
  rewrite(fout);

  write(fout,'                词法分析');
  writeln(fout);
  writeln(fout);
  write(fout,'(');
  write(fout,' name');
  write(fout,',');
  write(fout,' type');
  write(fout,',':3);
  write(fout,'index');
  write(fout,',');
  write(fout,' value');
  write(fout,',');
  write(fout,'line');
  write(fout,')');
  writeln(fout);
  writeln(fout);

  while(j<=wordlist_index) do
  begin
    write(fout,'(');
    write(fout,' ',wordlist[j].name:8);
    write(fout,',');
    write(fout,wordlist[j].index:4);
    write(fout,', ':4);      ///////
 //   write(fout,wordlist[j].symb_string:4);     //////
 //   write(fout,',':3);
    write(fout,wordlist[j].no:3);
    write(fout,', ':3);
    write(fout,wordlist[j].value:4);
    write(fout,', ':3);
    write(fout,wordlist[j].info:4,' ');
    write(fout,')');
    writeln(fout);
    inc(j);
  end;
  closefile(fout);

end;


procedure WriteToMemo3;       //向Memo3输入词法分析结果
var
  f:text;
  s:string;
begin
  chdir('C:\');
  assignfile(f,'temporary_result_word.txt');
  reset(f);
  MainForm.Memo3.Clear;
  while not eof(f) do
  begin
    readln(f,s);
    MainForm.Memo3.Lines.Append(s);
  end;
  closefile(f);
  DeleteFile('temporary_result_word.txt');
end;

procedure Clear_errormark;     //清除错误行标记
var
  i:integer;
begin
  if error_mark[1]=1 then MainForm.Shape1.Visible:=false;
  if error_mark[2]=1 then MainForm.Shape2.Visible:=false;
  if error_mark[3]=1 then MainForm.Shape3.Visible:=false;
  if error_mark[4]=1 then MainForm.Shape4.Visible:=false;
  if error_mark[5]=1 then MainForm.Shape5.Visible:=false;
  if error_mark[6]=1 then MainForm.Shape6.Visible:=false;
  if error_mark[7]=1 then MainForm.Shape7.Visible:=false;
  if error_mark[8]=1 then MainForm.Shape8.Visible:=false;
  if error_mark[9]=1 then MainForm.Shape9.Visible:=false;
  if error_mark[10]=1 then MainForm.Shape10.Visible:=false;
  if error_mark[11]=1 then MainForm.Shape11.Visible:=false;
  if error_mark[12]=1 then MainForm.Shape12.Visible:=false;
  if error_mark[13]=1 then MainForm.Shape13.Visible:=false;
  if error_mark[14]=1 then MainForm.Shape14.Visible:=false;
  if error_mark[15]=1 then MainForm.Shape15.Visible:=false;
  if error_mark[16]=1 then MainForm.Shape16.Visible:=false;
  if error_mark[17]=1 then MainForm.Shape17.Visible:=false;
  if error_mark[18]=1 then MainForm.Shape18.Visible:=false;
  if error_mark[19]=1 then MainForm.Shape19.Visible:=false;
  if error_mark[20]=1 then MainForm.Shape20.Visible:=false;
  if error_mark[21]=1 then MainForm.Shape21.Visible:=false;
  if error_mark[22]=1 then MainForm.Shape22.Visible:=false;
  if error_mark[23]=1 then MainForm.Shape23.Visible:=false;
  if error_mark[24]=1 then MainForm.Shape24.Visible:=false;
  if error_mark[25]=1 then MainForm.Shape25.Visible:=false;
  if error_mark[26]=1 then MainForm.Shape26.Visible:=false;
  if error_mark[27]=1 then MainForm.Shape27.Visible:=false;
  if error_mark[28]=1 then MainForm.Shape28.Visible:=false;
  if error_mark[29]=1 then MainForm.Shape29.Visible:=false;
  if error_mark[30]=1 then MainForm.Shape29.Visible:=false;
  for i:=1 to 30 do error_mark[i]:=0;
end;

procedure Set_errormark;
begin
  if error_mark[1]=1 then MainForm.Shape1.Visible:=true;
  if error_mark[2]=1 then MainForm.Shape2.Visible:=true;
  if error_mark[3]=1 then MainForm.Shape3.Visible:=true;
  if error_mark[4]=1 then MainForm.Shape4.Visible:=true;
  if error_mark[5]=1 then MainForm.Shape5.Visible:=true;
  if error_mark[6]=1 then MainForm.Shape6.Visible:=true;
  if error_mark[7]=1 then MainForm.Shape7.Visible:=true;
  if error_mark[8]=1 then MainForm.Shape8.Visible:=true;
  if error_mark[9]=1 then MainForm.Shape9.Visible:=true;
  if error_mark[10]=1 then MainForm.Shape10.Visible:=true;
  if error_mark[11]=1 then MainForm.Shape11.Visible:=true;
  if error_mark[12]=1 then MainForm.Shape12.Visible:=true;
  if error_mark[13]=1 then MainForm.Shape13.Visible:=true;
  if error_mark[14]=1 then MainForm.Shape14.Visible:=true;
  if error_mark[15]=1 then MainForm.Shape15.Visible:=true;
  if error_mark[16]=1 then MainForm.Shape16.Visible:=true;
  if error_mark[17]=1 then MainForm.Shape17.Visible:=true;
  if error_mark[18]=1 then MainForm.Shape18.Visible:=true;
  if error_mark[19]=1 then MainForm.Shape19.Visible:=true;
  if error_mark[20]=1 then MainForm.Shape20.Visible:=true;
  if error_mark[21]=1 then MainForm.Shape21.Visible:=true;
  if error_mark[22]=1 then MainForm.Shape22.Visible:=true;
  if error_mark[23]=1 then MainForm.Shape23.Visible:=true;
  if error_mark[24]=1 then MainForm.Shape24.Visible:=true;
  if error_mark[25]=1 then MainForm.Shape25.Visible:=true;
  if error_mark[26]=1 then MainForm.Shape26.Visible:=true;
  if error_mark[27]=1 then MainForm.Shape27.Visible:=true;
  if error_mark[28]=1 then MainForm.Shape28.Visible:=true;
  if error_mark[29]=1 then MainForm.Shape29.Visible:=true;
  if error_mark[30]=1 then MainForm.Shape29.Visible:=true;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -