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

📄 error.h

📁 我的编译原理课程设计。类PASCAL的语法
💻 H
字号:
void error(int n)
{
	void getsym();
	int getch();
	switch(n)
	{
	case 20:str.Format("20:illegal character :error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
		    file_error.Write(str,str.GetLength());
		    getch();
			getsym();break;
	case 2:if(cc>1)
		   {
			   str.Format("2:there should be a ident follow 'const':error in line %d colum %d%c%c",count_line-1,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();
		   }else 
		   {
			   str.Format("2:there should be a ident follow 'const':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());getch();getsym();
		   }break;
	case 4:if(cc>1)
		   {
			   str.Format("4:The ident already exists:error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();getsym();
		   }else 
		   {
			   str.Format("4:The ident already exists:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 1:if(cc>1)
		   {
			   str.Format("1:there should be  a '=' follow ident:error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();
		   }else 
		   {str.Format("1:there should be  a '=' follow ident:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
		   file_error.Write(str,str.GetLength());
		   }
		break;
	case 3:if(cc>1)
		   {
			   str.Format("3:there should be a number follow '=':error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();getsym();
		   }else 
		   {
			   str.Format("3:there should be a number follow '=':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 5:if(cc>1)
		   {
			   str.Format("5:missing ';':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());getch();//cc=0;ll=0;getch();
		   }else 
		   {
			   str.Format("5:missing ';':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 6:if(cc>1)
		   {
			   str.Format("6:there should be a ident follow 'var':error in line %d colum %d%c%c",count_line-1,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();getsym();
		   }else 
		   {
			   str.Format("6:there should be a ident follow 'var':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());getch();getsym();
		   }
		break;
	case 7:if(cc>1)
		   {
			   str.Format("7:there should be '=' following indent in statment:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());getch();cc=0;ll=0;getch();
		   }else 
		   {
			   str.Format("7:there should be '=' following indent in statment:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 8:if(cc>1)
		   {
			   str.Format("8:undeclared identifier:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());getch();cc=0;ll=0;getch();
		   }else 
		   {
			   str.Format("8:undeclared identifier:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 9:if(cc>1)
		   {
			   str.Format("9:missing '(':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();
		   }else 
		   {
			   str.Format("9:missing '(':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 10:if(cc>1)
		   {
			   str.Format("10:The ident doesn't exist:error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();
		   }else 
			{
			   str.Format("10:The ident doesn't exist:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 11:if(cc>1)
		   {
			   str.Format("11:expression error:error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();
		   }else 
			{
			   str.Format("11:expression error:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 12:if(cc>1)
		   {
			   str.Format("12:missing '(' follow if:error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();
		   }else 
			{
			   str.Format("12:missing '(' follow if:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 13:if(cc>1)
		   {
			   str.Format("13:missing ')' follow if:error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();
		   }else 
			{
			   str.Format("13:missing ')' follow if:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 19:if(cc>1)
		   {
			   str.Format("11:expression error:error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());getch();
		   }else 
			{
			   str.Format("11:expression error:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 18:if(cc>1)
		   {
			   str.Format("5:missing ';':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();getsym();
		   }else 
			{
			   str.Format("5:missing ';':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 21:if(cc>1)
		   {
			   str.Format("21:no meaning charactor:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();
		   }else 
			{
			   cc=0;ll=0;getch();str.Format("21:no meaning charactor:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 22:if(cc>1)
		   {
			   str.Format("12:missing '(' follow if:error in line %d colum %d%c%c",count_line,cc-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();getsym();
		   }else 
			{
			   str.Format("12:missing '(' follow if:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 23:if(cc>1)
		   {
			   str.Format("7:there should be '=' following indent in statment:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();getsym();
		   }else 
			{
			   str.Format("7:there should be '=' following indent in statment:error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	case 24:if(cc>1)
		   {
			   str.Format("24:there should be ident following 'for':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());cc=0;ll=0;getch();getsym();
		   }else 
			{
			   str.Format("24:there should be ident following 'for':error in line %d colum 'the end'%c%c",count_line-1,chr1,chr2);
			   file_error.Write(str,str.GetLength());
		   }
		break;
	}
}

⌨️ 快捷键说明

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