?? simpsc.cpp
字號:
// Simpsc.cpp: implementation of the Simpsc class.
//
//////////////////////////////////////////////////////////////////////
#include "Simpsc.h"
#include "pcode.h"
#include "Table.h"
#include "Grammar.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Simpsc::~Simpsc()
{
if(ChaTable) delete ChaTable;
if(gra) delete gra;
if(CodeList) delete CodeList;
pas.close();
}
void Simpsc::OpenFile(string &name)
{
string n;
n=name+".txt";
pas.open(n.data(),ios::in);
if(!pas)
{
cout<<"打開程序文件失??!\n";
exit(0);
}
else
{
ChaTable=new Table(this);
gra=new Grammar(this);
CodeList=new pcode;
}
}
bool Simpsc::WordCheck()
{
int i,j,row;
char astr[Longest];
string passage;
TokenFile.open("TokenFile.dat",ios::binary|ios::out);
if(!TokenFile)
{
cout<<"打開輸出文件失?。n";
exit(0);
}
j=0;
// cout<<pas.tellg()<<endl;
for(row=1;!pas.eof();row++)
{
pas.getline(astr,Longest,'\n');
passage.assign(astr);
i=0;
while(i<passage.length())
WordAnaly(passage,i,j,Token,row);
}
for(i=0;i<j;i++)
TokenFile.write((char*)&Token[i],sizeof(Word));
TokenFile.close();
cout<<"詞法分析結束,所有信息已經輸出到dat文件中"<<endl;
return true;
}
bool Simpsc::Compile()
{
return this->gra->Analysis(Token);
//gra->Analysis();
}
void Simpsc::DisplaySrcfile()
{
char astr[Longest];
int i;
// long pos=pas.tellg();
// pas.seekg(0L,ios::beg);
for(i=1;!pas.eof();i++)
{
pas.getline(astr,Longest,'\n');
cout<<i<<"\t"<<astr<<endl;
}
pas.seekg(0L,ios::beg);
pas.clear();
}
void Simpsc::Interpret()
{
CodeList->Interpret();
}
void Simpsc::ListCode()
{
CodeList->PrintCode();
}
void Simpsc::OutFile(string &name)
{
this->CodeList->OutToFile(name);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -