📄 test30.y
字号:
%{
#include <stdio.h>
#include "yy.tab.h"
extern FILE *yyin, *yyout;
extern int lineno;
extern int ofiletype;
int assigntype=0;
int outlineno=1;
int hangupprocline=-1;
int onhookline = -1;
int offhookline =-1;
int agenteventprocline = -1;
int waiteventprocline = -1;
int usercallinline = -1;
int userhangupline = -1;
int agentdigitline = -1;
int interserviceline = -1;
int strlines = 0;
#define heapsize 100
ststringheap vstringheap[heapsize];
stintheap vintheap[heapsize];
stconstant constant[CONSTANTSIZE];
boolresultheap boolresult[heapsize];
int int_k=0;int_k_count=0;
int string_k =0;int string_k_count=0;
int result_heap_k = 0;
int errcount = 0;
int current_bool_result = -1;
char szswitchname[100];
extern char szswitchend[100];
extern char nop[100];
extern char * filename;
extern int newstmt;
extern int nexttoken;
int assignstmtflag = 0;
int assignstmtflag2= 0;
int sectioncount = 0;
%}
%left '+' '-'
%left '*' '/' '%'
%union {
int iValue;
char szValue[1024];
}
%token <iValue> NUMBER
%token <szValue> STR
%token <szValue> ID
%type <szValue> string_bool_expression
%type <szValue> int_bool_expression
%type <szValue> expression
%token
STATESTART RETURN INIT PROC FUNID INT STRING
BREAK SWITCH CASE DEFAULT SF IF ELSE LEFTK RIGHTK
COLON GOTO PLAYFILE READDIGITS CONFPLAYFILE JOINCONF DIALOUT TALKWITH
RECFILE CONFRECFILE HANGUP LEFTC RIGHTC LEFTV RIGHTV LEFTVE RIGHTVE VVEE
NOTVVEE VE ELSEIF ELSESF VOID SQLSELECT SQLCOMMAND STOI ITOS COMMENT SETCHANTIMER
GETFREECHAN GETFREECONFNO GETFIELDVALUE GETAFFECTEDROW HANGUPPROC
GETSUBSTRING GETRAND GETRANDKEY FINDFILE JUMPAGENT GETNOWTIME
STMTEND ASSIGN PLUS MINUS TIMES DIV JUMPFLOW WHILE STRLEN LINKPCMFILE SLEEP
GOTOFLOW GOTOSUBFLOW SENDANC GETUSEDSECONDS GETDIALINTIME ENTERSECTION LEAVESECTION
ONHOOK OFFHOOK USERHANGUP USERCALLIN AGENTDIGIT AGENTREQ SWITCHAGENT AGENTCALLOUT AGENTIVRREQ LOGMSG RGOTO
LISTENAGENT BREAKAGENT GETCONFNOMEMBERS AGENTPLAYRING AGENTREQEX GETFREEIPCHANNO IPCALL MOD TIMESPAN SETDIALINTIME
CHECKINTSECTION CHECKSTRINGSECTION DATEDIFF GETUSEDCHAN HANGUPDEST STARTRECORD STARTLINERECORD AGENTIPCALL AGENTIPREQ IVRIPREQ CHECKNETCONNECTION ADDNETCONNECTION
SETDIALOUTORICALLEENUM VTTALKWITH VTSETSCALE SETPROCEVENT AGENTEVENTPROC AGENTEVENTPROCSTART AGENTEVENTPROCEND WAITEVENTPROC LJOINCONF RESETCONF SHAREFLOWVAR
CHECKDIRECTORY RESETAGENT CONFSTOPFILE JOINMULTICONF LINEISOFFHOOK GETRECORDSECONDS STARTRECORDCTOC GETFREECHANWITHLINK SETORICALLEE REQUESTSERVICE INTERSERVICE
%%
program:
declaration_list
;
declaration_list:
declaration_list declaration |
declaration
;
declaration:
var_declaration |
state_declaration |
hangup_declaration |
onhook_declaration |
offhook_declaration |
usercallin_declaration |
userhangup_declaration |
agentdigit_declaration |
agenteventproc_declaration |
waiteventproc_declaration |
interservice_declaration
;
hangup_declaration:
statehangupproc leftk_identifer init leftk_identifer hangupstatement_list rightk_identifer rightk_identifer
;
onhook_declaration:
stateonhook leftk_identifer init leftk_identifer hangupstatement_list rightk_identifer rightk_identifer
;
offhook_declaration:
stateoffhook leftk_identifer init leftk_identifer statement_list rightk_identifer proc leftk_identifer statement_list rightk_identifer rightk_identifer
|
stateoffhook leftk_identifer init leftk_identifer statement_list rightk_identifer rightk_identifer
;
usercallin_declaration:
stateusercallin leftk_identifer init leftk_identifer statement_list rightk_identifer proc leftk_identifer statement_list rightk_identifer rightk_identifer
|
stateusercallin leftk_identifer init leftk_identifer statement_list rightk_identifer rightk_identifer
;
userhangup_declaration:
stateuserhangup leftk_identifer init leftk_identifer statement_list rightk_identifer proc leftk_identifer statement_list rightk_identifer rightk_identifer
|
stateuserhangup leftk_identifer init leftk_identifer statement_list rightk_identifer rightk_identifer
;
agentdigit_declaration:
stateagentdigit leftk_identifer init leftk_identifer statement_list rightk_identifer proc leftk_identifer statement_list rightk_identifer rightk_identifer
|
stateagentdigit leftk_identifer init leftk_identifer statement_list rightk_identifer rightk_identifer
;
agenteventproc_declaration:
stateagenteventproc leftk_identifer init leftk_identifer statement_list rightk_identifer proc leftk_identifer statement_list rightk_identifer rightk_identifer
|
stateagenteventproc leftk_identifer init leftk_identifer statement_list rightk_identifer rightk_identifer
;
waiteventproc_declaration:
statewaiteventproc leftk_identifer init leftk_identifer statement_list rightk_identifer proc leftk_identifer statement_list rightk_identifer rightk_identifer
|
statewaiteventproc leftk_identifer init leftk_identifer statement_list rightk_identifer rightk_identifer
;
interservice_declaration:
stateinterservice leftk_identifer init leftk_identifer statement_list rightk_identifer proc leftk_identifer statement_list rightk_identifer rightk_identifer
|
stateinterservice leftk_identifer init leftk_identifer statement_list rightk_identifer rightk_identifer
;
statehangupproc:
STATESTART HANGUPPROC
{
if(hangupprocline!=-1)
{
printf("%s(%d): syntax error: hangupproc only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = hangupproc old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(HANGUPPROC1));
hangupprocline = outlineno-1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,HANGUPPROC1);
hangupprocline = outlineno-1;
}
}
;
stateonhook:
STATESTART ONHOOK
{
if(onhookline!=-1)
{
printf("%s(%d): syntax error: onhook only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = onhook old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(ONHOOK1));
onhookline = outlineno-1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,ONHOOK1);
onhookline = outlineno-1;
}
}
;
stateinterservice:
STATESTART INTERSERVICE
{
if(interserviceline!=-1)
{
printf("%s(%d): syntax error: interservice only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = interservice old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(INTERSERVICE1));
interserviceline = outlineno-1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,INTERSERVICE1);
interserviceline = outlineno-1;
}
}
;
stateoffhook:
STATESTART OFFHOOK
{
if(offhookline!=-1)
{
printf("%s(%d): syntax error: offhook only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = onhook old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(OFFHOOK1));
offhookline = outlineno-1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,OFFHOOK1);
offhookline = outlineno-1;
}
}
;
stateagenteventproc:
STATESTART AGENTEVENTPROC
{
if(agenteventprocline!=-1)
{
printf("%s(%d): syntax error: agenteventproc only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = agenteventproc old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(AGENTEVENTPROC1));
agenteventprocline = outlineno-1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,AGENTEVENTPROC1);
agenteventprocline = outlineno-1;
}
}
;
statewaiteventproc:
STATESTART WAITEVENTPROC
{
if(waiteventprocline!=-1)
{
printf("%s(%d): syntax error: waiteventproc only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = waiteventproc old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(WAITEVENTPROC1));
waiteventprocline = outlineno-1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,WAITEVENTPROC1);
waiteventprocline = outlineno-1;
}
}
;
stateusercallin:
STATESTART USERCALLIN
{
if(usercallinline!=-1)
{
printf("%s(%d): syntax error: usercallin only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = usercallin old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(USERCALLIN1));
usercallinline = outlineno-1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,USERCALLIN1);
usercallinline = outlineno-1;
}
}
;
stateuserhangup:
STATESTART USERHANGUP
{
if(userhangupline!=-1)
{
printf("%s(%d): syntax error: userhangup only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = userhangup old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(USERHANGUP1));
userhangupline = outlineno-1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,USERHANGUP1);
userhangupline = outlineno-1;
}
}
;
stateagentdigit:
STATESTART AGENTDIGIT
{
if(agentdigitline!=-1)
{
printf("%s(%d): syntax error: agentdigit only define once ! \n",filename,lineno);
errcount ++;
}
fprintf(dumpfile,"读取到state statestart: name = userhangup old_boolresult = %d,new_boolresult = %d \n",current_bool_result,10);
inboolresult(current_bool_result);
setboolresult(10);
if(ofiletype==1)
{
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(AGENTDIGIT1));
agentdigitline = outlineno -1;
}
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,AGENTDIGIT1);
agentdigitline = outlineno-1;
}
}
;
hangupstatement_list:
hangupstatement_list hangupstatement |
hangupstatement
;
hangupstatement:
switch_stmt |
if_stmt |
sf_stmt |
assign_stmt |
declaration |
hangup |
sqlcommand |
sqlselect |
while_stmt |
linkpcmfile |
beginsection |
endsection |
logmsg |
agentplayring |
;
var_declaration:
string_declaration |
int_declaration
;
assign_stmt: assign_head myexpression STMTEND
{
if(ofiletype==1)
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(AGN_END));
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,AGN_END);
}
}
;
myexpression:
sysfun_expression |
expression_list
;
sysfun_expression:
GETFREECHAN LEFTC RIGHTC
{
if(assigntype!=0)
{
printf("%s(%d): syntax error: getfreechan type conflict \n",filename,lineno);
errcount ++;
}
if(ofiletype==1)
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(GETFREECHAN1));
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,GETFREECHAN1);
}
}
|
GETUSEDCHAN LEFTC RIGHTC
{
if(assigntype!=0)
{
printf("%s(%d): syntax error: getusedchan type conflict \n",filename,lineno);
errcount ++;
}
if(ofiletype==1)
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(GETUSEDCHAN1));
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,GETUSEDCHAN1);
}
}
|
GETFREECONFNO LEFTC RIGHTC
{
if(assigntype!=0)
{
printf("%s(%d): syntax error: getfreeconfno type conflict \n",filename,lineno);
errcount ++;
}
if(ofiletype==1)
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(GETFREECONFNO1));
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,GETFREECONFNO1);
}
}
|
GETFREEIPCHANNO LEFTC RIGHTC
{
if(assigntype!=0)
{
printf("%s(%d): syntax error: getfreeipchanno type conflict \n",filename,lineno);
errcount ++;
}
if(ofiletype==1)
fprintf(yyout,"%5d:%10s\n",outlineno++,looktokentable(GETFREEIPCHANNO1));
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\n",outlineno,GETFREEIPCHANNO1);
}
}
|
GETFREECHANWITHLINK LEFTC ID RIGHTC
{
int i=0;
if(assigntype!=0)
{
printf("%s(%d): syntax error: getfreechanwithlink type conflict \n",filename,lineno);
errcount ++;
}
i = lookstringtable($3);
if(i==0)
{
printf("%s(%d): syntax error: undeclared identifier '%s' \n",filename,lineno,$3);
errcount ++;
}
else if(i==2)
{
printf("%s(%d): syntax error: getfreechanwithlink function need a int-type parameter \n",filename,lineno);
errcount++;
}
if(ofiletype==1)
fprintf(yyout,"%5d:%10s\t%s\n",outlineno++,looktokentable(GETFREECHANWITHLINK1),$3);
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\t%s\n",outlineno,GETFREECHANWITHLINK1,$3);
}
}
|
GETFREECHANWITHLINK LEFTC NUMBER RIGHTC
{
if(assigntype!=0)
{
printf("%s(%d): syntax error: getfreechanwithlink type conflict \n",filename,lineno);
errcount++;
}
if(ofiletype==1)
fprintf(yyout,"%5d:%10s\t%d\n",outlineno++,looktokentable(GETFREECHANWITHLINK2),$3);
else
{
outlineno++;
fprintf(yyout,"%5d:\t%5d\t%d\n",outlineno,GETFREECHANWITHLINK2,$3);
}
}
|
GETCONFNOMEMBERS LEFTC ID RIGHTC
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -