📄 编译程序设计与实现.cpp
字号:
// ANewOne.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "ANewOne.h"
//#include "CToken.h"
#include "ExpSet.h"
//#include "ExpToken.h"
#include "GenTree.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
cout<<"词法部分的Token序列"<<endl;
int i1=0;
int i2=0;
CTokens T;
int e=0;
int k=0;
int p=0;
k=T.Open("3.txt");
e=T.ReadToken(&i1,&i2);
p=T.GetTokenNum();
cout<<"词法分析后Token数: "<<p<<endl;//print out the number of token
int q=0;
CToken TmpToken_T;
cout<<endl;
for(q;q<p;q++)//echo
{
T.GetToken(&TmpToken_T,q);
printToken(TmpToken_T);
}
//语法栈部分
cout<<"语法栈中的表达式类型 "<<endl;
int i=5;
CExpMan Tmp;
Tmp.Open("ExpSet.txt");
i=Tmp.ReadExp();
cout<<i<<endl;
Tmp.PrintExp();
// 初始变量栈中内容
cout<<"初始变量栈中内容 "<<endl;
CVarMan TCV;
TCV.GenVarStack(&T);
TCV.PrintVarS();
//语法分析的表达式向量生成部分
cout<<"在表达式栈中的内容"<<endl;
CTokens* T3=&T;
ETokenMan T2;
T2.GetExp(T3);
//结点生成部分
cout<<"结点生成部分"<<endl;
CTree TTree;
TTree.GetTree(&T2);
TTree.PrintTreeToken();
//// 程序执行完后变量栈中内容
cout<<"程序执行完后变量栈中内容----执行结果: "<<endl;
TCV.GenFinalES(&T2);
TCV.PrintVarS();
}
return nRetCode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -