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

📄 micro.cpp

📁 现代编译原理C语言实现中的第二章的编译器实现。并在书中的基础上有所改变。包括词法语法分析及汇编代码生成。
💻 CPP
字号:
// Micro.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Lex.h"
#include "Syntax.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstdlib>
#include <ctime>

using namespace std;
/*
begin    0
  a := 25;
4
10
5
8
end
3
^Z  -1
13
*/

/*
extern struct AA;
struct AA {
};
//int AA::a;
class CA {public:
	static int a;
};
int CA::a;
*/
FILE * outfp = NULL;
FILE * infp = NULL;
char * outfile = "t1.out.txt";
char *  infile = "mc.in.txt";
bool   infromfile	= true;
bool   out2file	= true;


int _tmain(int argc, _TCHAR* argv[])
{
	/*
	clock_t  beg = clock();
	system("pause");
	clock_t  end = clock();
	cout<<(end)/CLOCKS_PER_SEC<<endl;
	if( 2 > 1 ) {
		return 1;
	}	// JNWKADCM
	*/
	/*  // for test lex
	token tk;
	while( (tk = scanner()) != SCANEOF ) {
		printf("%d  %s\n", tk, getTokenText(tk));
	}
	printf("%d  %s\n", tk, getTokenText(tk));
	*/
	
	// 选择输出到文件
	if( out2file ) {
		//outfp = fopen(outfile, "w");
		outfp = freopen(outfile, "w", stdout);
		if( ! outfp ) {
			error("create file fail.");
		}
	}
	// 选择从文件输入
	if( infromfile ) {
		//infp = fopen(infile, "r");
		infp = freopen(infile, "r", stdin);
		if( ! infp ) {
			error("file not exists.");
		}
	}
	system_goal();


	if( out2file ) {
		freopen("CON", "w", stdout);//   printf("I'm back.\n");
	}
	if( infromfile ) {
		freopen("CON", "r", stdin);
	}
	//fclose(outfile);
	//fclose(infp);
	
	return 0;
}

⌨️ 快捷键说明

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