📄 error.cpp
字号:
// Error.cpp: implementation of the Error class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SmartC.h"
#include "Error.h"
#include "MyEditView.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#if !defined INTOTSTRINTTOSTR2222
#define INTOTSTRINTTOSTR2222
void inttostr4(int n,char *pchar)
{
int i=0;
char temp[10];
while(n!=0)
{
temp[i]=n%10+'0';
i++;
n/=10;
}
while(i<4)//前面加0凑足4位数
{
temp[i]='0';
i++;
}
for(i--;i>=0;i--)
{
*pchar=temp[i];
pchar++;
}
*pchar=0;//结尾
}
#endif //INTOTSTRINTTOSTR2222
Error::Error(CSmartCDoc* p)
{
pdoc=p;
}
void Error::ShowError(int type,int lineno)
{
char str[200];
char temp[5];
strcpy(str,"错误类型");
inttostr4(type,temp);
strcat(str,temp);
strcat(str,",在第");
inttostr4(lineno,temp);
strcat(str,temp);
strcat(str,"行:");
// cout<<"错误类型"<<type<<",在第 "<<lineno<<"行:";
switch(type)
{
case 0:
{
strcat(str," 无法识别的符号");
pdoc->insertline(1,str);
// cout<<" 无法识别的符号"<<endl;
break;
}
case NOTICE:
{
strcat(str," 标注符号/*不完整");
pdoc->insertline(1,str);
// cout<<" 标注符号/*不完整."<<endl;
break;
}
case ORSY:
{
strcat(str," 无法识别的符号:");
strcat(str," \"|\"");
pdoc->insertline(1,str);
// cout<<" 无法识别的符号:"<<"\"|\""<<endl;
break;
}
case ANDSY:
{
strcat(str," 无法识别的符号:");
strcat(str," \"&\"");
pdoc->insertline(1,str);
// cout<<" 无法识别的符号:"<<"\"&\""<<endl;
break;
}
case CSTRINGSY:
{
strcat(str," 还缺少一个\".");
pdoc->insertline(1,str);
// cout<<" 还缺少一个\"."<<endl;
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -