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

📄 main.cpp

📁 一个简单的C语言子集的编译器,一个简单的C语言子集的编译器
💻 CPP
字号:
#pragma warning(disable:4786)

#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include "global.h"
#include "scan.h"
#include "parse.h"
#include "util.h"
#include "analyze.h"
#include "gencode.h"

using namespace std;
void copyright()
{
	cout<<"\nC Minus Compiler\n";
	cout<<"According to the design in the book\n"
		"\"Compiler Construction Principles and Practice\""
		" by Kenneth C. Louden\n";
	cout<<"Generate TM code, execute with TM.exe\n\n";
	cout<<"Wrriten by bood\n";
	cout<<"Homepage: http://boodweb.126.com\n";
	cout<<"Email: boodweb@yahoo.com.cn\n";
}
int main(int argc,char *argv[])
{
	init();
	copyright();
	if(argc<2){
		cout<<"No source file specified."<<endl;
		cout<<"Usgae: cminus <source file>\n";
		return 0;
	}
	fsource.open(argv[1]);
	ftoken.open("token.txt");
	fsyntax.open("syntax.txt");
	fsymbol.open("symbol.txt");
	fcode.open("code.txt");
	TreeNode *p=parse();
	PrintSyntaxTree(p,fsyntax);
	BuildSymbolTable(p);
	fsymbol<<"name"<<"\t\t"<<"location"
		<<"\t\t"<<"lineno"<<"\t\t"<<
		"nestlevel"<<endl;
	PrintOneTable(&GlobalBucket,fsymbol);
	PrintSymbolTable(p,fsymbol);
	TypeCheck(p);
	genCode(p);
	return 0;
}

⌨️ 快捷键说明

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