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

📄 mainapp.c

📁 C编译器,在VC6.0环境下开发
💻 C
字号:
#include	"Header.h"
#include	"GenCode.h"
#include	"GBStrTab.h"
#include	"LYCond.h"
#include	"Error.h"
#include	<stdio.h>
#include	<stdlib.h>

//#include	<dir.h>
#define		MAXPATH		255

#include	<string.h>
#include	<assert.h>

char    in[MAXPATH], out[MAXPATH];

int	yyparse();

void	dispCopyRight()
{
	puts("Micro C Compiler    Version 1.0");
	puts("Copyright (c) 2001 by Ocean_LR Group.  All rights reserved.\n");
}

void	get_in_out(int argc, char *argv[])
{
	char   	*p;

	// gen in file name
	strcpy(in, argv[1]);    //in="try"
	p =	strchr(in, '.');
	if ( !p )
		strcat(in, ".c");

	// gen out file name
	if (argc > 2)
	{
		strcpy(out, argv[2]);
		p =	strchr(out, '.');
		if ( !p )
			strcat(out, ".asm");
	}
	else
	{
		strcpy(out, in);
		p =	strchr(out, '.');
		assert( p );
		strcpy(p, ".asm");
	}
}

void 	main(int argc, char *argv[])
{
	int		ret;

	dispCopyRight();
	//argv[1]="add1" ;
	if (argc < 2)
	{
		printf("Usage: MC source[.c] [ output[.asm] ]\n");
	//	return	1;
	}

	get_in_out(argc, argv);

	printf("Compiling file %s......\n", in);

	InitYacc(in);

	gen_data_segment_head();
	gen_code_segment_head();

	ret = yyparse();

	// gen string tab code
	gen_string_tab(get_string_tab_head());

	gen_data_segment_end();
	gen_code_segment_end();
	if ( !is_main_function_exist() )
	{
		yyerror("check main error: unresolved external symbol _main");
		user_exit(1);
	}

	DestoryYacc(out);

	if ( !ret )
		puts("OK, Compile Success\n");

#ifndef NDEBUG
	printf("debug info in debug.txt\n");
#endif

//	return	ret;
}


⌨️ 快捷键说明

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