解释配置文件时解释器传递信息 - luosiwei-cmd/CarYon GitHub Wiki

解释配置文件时解释器传递信息

在写好您的配置文件之后,请运行 control.exe,如果屏幕显示:

Analysis end with succeed.

Please check the analysis.log for more information.

这就代表解释成功了,已经生成了完好的 test.cpp,这个时候您可以访问日志 analysis.log 查看信息。然后打开 test.cpp,将 caryon.h 包含到当前目录,编译运行即可生成数据。

如果显示:

Analysis failed. Please check the analysis.log for more information.

这个时候代表解释您的配置文件时出现了错误,下面我们一起来看看错误信息。

错误信息解释

所有错误信息在analysis.log中查看

[ERR] on row x , more than 1 makedata operation is not be allowed. | The makedata operation may be not in the fitst row. Plese check.

这个信息的出现代表您不符合makedata命令的条件:在第一行并且有且仅有一个。

[ERR] on row x, unknown operation found.

这个信息代表在第 x 行前后出现了解释器不认得的东西。

[ERR] there is not a makedata opertion in your compile file.

这代表您的程序中没有makedata命令。

[ERR] cannot find file: control.ini.

在您的目录中找不到 control.ini

[ERR] on row x, the variable name is wrong.

定义的变量不符合标识符命名规则。

[ERR] on row x, the variable name has already been named.

定义的变量重名。

[ERR] on row x, there is no variable name ______.

找不到变量。

[ERR] The for do not have an end.

出现循环没有结尾。

[ERR] The continue/break/sf is not in a for.

continue/break/sf并不在for循环内。

[ERR] The fi is not in a if.

fi 不在 if 内。

[ERR] A/Some if(s) do not have an end.

存在 if 没有结尾,即 fi

以 [LOG] 开头的信息解释

代表生成了xxx,这里见字面意思。

下面列举所有可能出现的 [LOG]:

[LOG] Makein function was written successfully.
[LOG] Make a random number successfully.
[LOG] Make a number successfully.
[LOG] Make a string or a space successfully.
[LOG] Make a random string successfully.
[LOG] Add int variable x successfully.
[LOG] Assign variable x to y successfully.
[LOG] Make a variable number successfully.
[LOG] Assign  variable x with a random number successfully.
[LOG] Add a for successfully.
[LOG] End a for successfully.
[LOG] Add a "continue" successfully.
[LOG] Add a break successfully.
[LOG] Add an if successfully.
[LOG] End an if successfully.
[LOG] Add a for with a variable end successfully.

以 [CHECKER] 开头的信息解释

这是某个判断函数针对其判断结果的日志信息,您可以在这里具体查看哪里出现了问题。

下面是几个 [CHECKER] 函数的源码:

bool isvari(string type){
	clog<<"[CHECKER] Checking if "<<type<<" is a variable name.\n";
	if(!((type[0]>='a' and type[0]<='z')or(type[0]>='A' and type[0]<='Z')or(type[0]=='_')or(type[0]=='$'))){
		return false;
	}
	for(int i=1;i<type.size();i++){
		if(!((type[i]>='a' and type[i]<='z')or(type[i]>='A' and type[i]<='Z')or(type[i]=='_')or(type[i]=='$')or(type[i]>='0' and type[i]<='9'))){
			clog<<"[CHECKER] "<<type<<" is not a variable name.\n";
			return false;   
		}
	}
	clog<<"[CHECKER] "<<type<<" is a variable name. Accept.\n";
	return true;
}
bool alreadyhave(string type){
	clog<<"[CHECKER] Checking if variable "<<type<<" has already used.\n";
	for(int i=0;i<_i;i++){
		if(_variable[i]==type){
			clog<<"[CHECKER] Variable "<<type<<" has already used.\n";
			return false;
		}
	}
	clog<<"[CHECKER] Variable "<<type<<" has not been used yet.\n";
	return true;
}
string maketab(){
	clog<<"[CHECKER] Checking how many space(s) will be used.\n";
	string temp;
	temp="        ";
	tab_cnt=if_cnt+for_cnt;
	int i;
	for(i=0;i<tab_cnt;i++){
		temp+="    "; 
	}
	clog<<"[CHECKER] For row "<<CNT<<", there will be "<<i*4+8<<" space(s) here.\n";
	return temp;
}
bool endForc(){
	clog<<"[CHECKER] Checking if sf/continue/break is in a fs.\n";
	if(for_cnt){
		clog<<"[CHECKER] Sf/continue/break is in a fs.\n";
		return true;
	}
	else{
		clog<<"[CHECKER] Sf/continue/break is not in a fs.\n";
		return false;
	}
}
bool endIfc(){
	clog<<"[CHECKER] Checking if fi is in an if.\n";
	if(if_cnt){
		clog<<"[CHECKER] Fi is in an if.\n";
		return true;
	}
	else{
		clog<<"[CHECKER] Fi is not in an if.\n";
		return false;
	}
}