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

📄 test30.l

📁 使用flex和bison
💻 L
📖 第 1 页 / 共 3 页
字号:
%{
#include "yy.tab.h"
int lineno = 1;
int definestmtflag = 0;
char linebuf[500];
char linebuftemp[100];
extern char *filename;
extern int newstmt;
extern int errcount;
extern int string_k;
int nexttoken = -1;
int instring = 0;
extern int assignstmtflag;
extern int assignstmtflag2;
int hangupstate=0;
int sectionflag = 0;
int sectionk = 0;
void printtokenerror(int nexttoken,char*curtoken)
{
	if(nexttoken==LEFTK)
	{
			printf("%s(%d): syntax error: miss '{'   before identifer  '%s' \n",filename,lineno,curtoken);
			errcount ++;	
	}	
	nexttoken = -1;
}
%}

%%
[ \t]  ;
#.* ;
"state"  {
    if(nexttoken!=-1)
	{
		printtokenerror(nexttoken,"state");
	}
	if(string_k!=0)
	{
			printf("%s(%d): syntax error: miss '}' or {''  near identifer  'state' \n",filename,lineno);
			errcount ++;
	}
	
	return STATESTART;
}
"init"  {
	if(nexttoken!=-1)
	{
		printtokenerror(nexttoken,"init");
	}
	nexttoken = LEFTK;
	

	return INIT;
}
"proc"  {
	if(hangupstate==1)
	{
		printf("%s(%d): syntax error: hangupproc only init body \n",filename,lineno);
			errcount ++;	
	}
	if(nexttoken!=-1)
	{
		printtokenerror(nexttoken,"proc");
	}
	nexttoken = LEFTK;
	
	return PROC;
}
"string" {
		 if(nexttoken!=-1)
		 {	
			printtokenerror(nexttoken,"string");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'string' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		definestmtflag = 1;
		

		return STRING;
}
"break"  {
		if(nexttoken!=-1)
		 {
		 printtokenerror(nexttoken,"break");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'break' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
			

		return BREAK;
}
"switch"  {
		if(nexttoken!=-1)
		 {
		 printtokenerror(nexttoken,"switch");
 		}
			

	return SWITCH;
}
"case"   {
		if(nexttoken!=-1)
		 {
		 printtokenerror(nexttoken,"case");
 		}
		

	return CASE;
}
"int"   {
		if(nexttoken!=-1)
		{
			 printtokenerror(nexttoken,"int");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'int' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		definestmtflag = 1;
		

		return  INT;
}
"default"  {
		if(nexttoken!=-1)
		{
			 printtokenerror(nexttoken,"default");
 		}
			 

		return DEFAULT;
}
"if" 	{
		if(nexttoken!=-1)
		{
			 printtokenerror(nexttoken,"if");
 		}
		  

	 return IF;
}
"sf"    {
		 if(nexttoken!=-1)
		 {
				 printtokenerror(nexttoken,"sf");
 		}
			

	 return SF;
 }
"while"    {
		 if(nexttoken!=-1)
		 {
				 printtokenerror(nexttoken,"while");
 		}
			

	 return WHILE;
 }


"else"  {
		 if(nexttoken!=-1)
		 {
				 printtokenerror(nexttoken,"else");
 		}
		

	 return ELSE;
}
"elsesf"  {
		if(nexttoken!=-1)
		 {
				 printtokenerror(nexttoken,"elsesf");
 		}
			 

	 return ELSESF;
}
"elseif"  {
		if(nexttoken!=-1)
		 {
				 printtokenerror(nexttoken,"elseif");
 		}
			

	return ELSEIF;
}
"void"	  return VOID;
"goto"	 {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no goto stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
			printtokenerror(nexttoken,"goto");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'goto' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
			 

		return GOTO;
}
"rgoto"	 {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no goto stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
			printtokenerror(nexttoken,"rgoto");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'rgoto' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
			 

		return RGOTO;
}
"beginsection"  {
		if(nexttoken!=-1)
		 {
		 printtokenerror(nexttoken,"beginsection");
 		}
		if(sectionflag!=0)
		 {
			printf("%s(%d): syntax error: beginsection \n",filename,lineno);
			errcount ++;
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'beginsection' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		sectionflag = 1;	
	    sectionk = 0;
	return ENTERSECTION;
}
"endsection"  {
		if(nexttoken!=-1)
		 {
		 printtokenerror(nexttoken,"endsection");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'endsection' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		if(sectionflag!=1)
		 {
			printf("%s(%d): syntax error: endsection \n",filename,lineno);
			errcount ++;
 		}
		if(sectionk!=0)
		 {
			printf("%s(%d): syntax error: endsection not pipei \n",filename,lineno);
			errcount ++;
 		}
		sectionk=0;
		sectionflag = 0;	

	return LEAVESECTION;
}
"sleep"    {
		 if(nexttoken!=-1)
		 {
				 printtokenerror(nexttoken,"sleep");
 		}
		newstmt = 0;	

	 return SLEEP;
 }

"playfile"  {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no playfile stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
			printtokenerror(nexttoken,"playfile");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'playfile' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return PLAYFILE;
}

"gotoflow"  {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no gotoflow stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
			printtokenerror(nexttoken,"gotoflow");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'gotoflow' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return GOTOFLOW;
}

"gotosubflow"  {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no gotosubflow stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
			printtokenerror(nexttoken,"gotosubflow");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'gotosubflow' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return GOTOSUBFLOW;
}

"readdigits"   {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no readdigits stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"readdigits");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'readdigits' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return READDIGITS;
}
"resetagent"   {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no readdigits stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"resetagent");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'resetagent' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return RESETAGENT;
}
"confplayfile"   {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no confplayfile stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"confplayfile");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'confplayfile' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
			

		return CONFPLAYFILE;
}

"confstopfile"   {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no confstopfile stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"confplayfile");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'confstopfile' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
			

		return CONFSTOPFILE;
}


"joinconf"    {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no joinconf stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"joinconf");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'joinconf' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return JOINCONF;
}

"joinmulticonf"    {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no joinmulticonf stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"joinmulticonf");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'joinmulticonf' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return JOINMULTICONF;
}
"ljoinconf"    {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no ljoinconf stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"ljoinconf");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'ljoinconf' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return LJOINCONF;
}
"lineisoffhook"    {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: lineisoffhook should no ljoinconf stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"lineisoffhook");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'lineisoffhook' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		

		return LINEISOFFHOOK;
}
"dialout"   {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no dialout stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"dialout");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'joinconf' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		
		 return DIALOUT;
}
"ipcall"   {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no ipcall stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"ipcall");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'ipcall' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		
		 return IPCALL;
}
"agentipcall"   {
		if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no ipcall stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"agentipcall");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'agentipcall' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
		
		 return AGENTIPCALL;
}
"datediff"   {
	
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"datediff");
 		}
	
		
		 return DATEDIFF;
}
"talkwith"    {
			if(hangupstate==1)
		{
			printf("%s(%d): syntax error: hangupproc should no talkwith stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"talkwith");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'talkwith' \n",filename,lineno);
			errcount ++;
		}
		newstmt = 0;
			 

		 return TALKWITH;
}
"shareflowvar"    {
			if(hangupstate==1)
		{
			printf("%s(%d): syntax error: shareflowvar should no talkwith stmt \n",filename,lineno);
				errcount ++;	
		}
		if(nexttoken!=-1)
		 {
				printtokenerror(nexttoken,"shareflowvar");
 		}
		if(newstmt==0) 	
		{
			printf("%s(%d): syntax error: missing ';' before identifier 'shareflowvar' \n",filename,lineno);
			errcount ++;

⌨️ 快捷键说明

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