pascal.cpp

来自「近日学习编译原理课程」· C++ 代码 · 共 40 行

CPP
40
字号
#include <stdio.h>
#include <stdlib.h>#include "parser.h"#include "string.h"

#ifndef _DEBUG
#define _DEBUG
#endif

int main(int argc, char* argv[])
{	if(argc>1)
	{		strcpy(sourcefile,argv[1]);		register char* cp;		cp=&sourcefile[strlen(sourcefile)]-1;		in=fopen(sourcefile,"r");		while((cp>=sourcefile)&&(*cp!='.')&&(*cp!='\\'))cp--;		if(*cp=='.')*cp=0;	}
#ifdef _DEBUG	else{		strcpy(sourcefile,"example");		in=fopen("example.pas","r");	}#endif	if(in==NULL){		printf("请在屏幕输入源文件,按ctrl+z结束输入\n");		in=0;	}	out=fopen("out.txt","w");
	fprintf(out, "%-8s%-8s%s\n-----------------------------------\n", "LineNO", "Type", "Value");	while(lex()!=0);//print_result(out);	fclose(out);	if(in!=NULL)fclose(in);

	system("edit out.txt");	return 0;}

⌨️ 快捷键说明

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