📄 main.cpp
字号:
#include"stdafx.h"
using namespace std;
void main()
{
string tempF;
cout<<"Please input the name of the source file"<<endl;
cin>>tempF;
SyntaxAnalyzer myAnalyzer;
myAnalyzer.initialize(tempF);
ofstream output;
tempF="r"+tempF;
output.open(tempF.c_str());
string message="";
while(true)
{
message=myAnalyzer.parse();
if(message!="Parsing ended")
{
if(message[message.length()-1]==' ')
{
output<<setw(40)<<transfer(message.substr(0,message.length()-1))
<<" ->"+transSeq(myAnalyzer.getCurrentProduction()->entry)<<endl
//this sentence output the production used.
<<setw(40)<<"ε"<<endl;
}
else if(message.length()>6)
{
output<<setw(40)<<message<<" "<<myAnalyzer.getLine()<<endl;
}
else
{
if(islower(message[1]))
{
output<<setw(10)<<transfer(message)<<endl;
}
else
{
output<<setw(40)<<transfer(message)<<" "<<"->"+transSeq(myAnalyzer.getCurrentProduction()->entry)<<endl;
}
}
}
else
{
output<<setw(40)<<message;
break;
}
}
cout<<"Work Done"<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -