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

📄 main.c

📁 北京航空航天大学计算机系要求的编译器大作业。大概6000行代码。
💻 C
字号:
/***************************************
By BHU 35060122 Peng Hui;
2008.02
description:
A small compiler to translate a C program to 80X80 Assembly Code
***************************************/


#include"Global.h"

void main(int args,char *argv[])
{
	MCode *tt;
	FILE *mcode;

	temp = fopen("myfiles/temp.dat","w");
	errlog = fopen("myfiles/errlog.dat","w");
	fout = fopen("myfiles/out.txt","w");
	mcode = fopen("myfiles/mcode.txt","w");
	
	if(args != 2)
	{ 
		printf("Usage:Compiler filename/file path \n");
		return;
	}

	fin = fopen(argv[1],"r");

	if(fin == NULL)
	{
		printf("File not exist!\n");
		printf("Usage:Compiler filename/file path \n");
		getchar();
		return;
	}

	scan();
	fclose(fout);
	fclose(temp);
	if(error)
	{
		printf("there is some error(s)\n");
		printf("See errlog.dat\n");
		return;
	}
	temp = fopen("myfiles/out.txt","r");

	NextSym(temp);
	Program();
	fclose(temp);

	if(error)
	{
		printf("there is some error(s)\n");
		printf("See errlog.dat\n");
		return;
	}

	temp = fopen("myfiles/out.txt","r");
	NextSym(temp);
	AnaProgram();
	
	if(error)
	{
		printf("there is some error(s)\n");
		printf("See errlog.dat\n");
		return;
	}

	tt = head;
	while(tt != NULL)
	{
		fprintf(mcode,"%s\t%s\t%s\t%s\t%s\n",tt->label,tt->op,tt->ad1,tt->ad2,tt->ad3);
		tt = tt->next;
	}

	fclose(mcode);
//	printf("%d\n",INT);
	
	toAsm();
	
	printf("Compile success!\n");
	
	
	fclose(temp);
}

⌨️ 快捷键说明

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