📄 userflow.cpp
字号:
pIdentyString=NULL;
if(!ExpressionRead(pIdentyString,dwIdentyId,dwIdenty,dwExpr)){
WriteError(pName,m_icLine,pIdentyString,"error cexpression");
m_ierror++;
break;
}
m_LineCode.Add(dwExpr);
if(dwIdenty!=WORD_THEN){
WriteError(pName,m_icLine,pIdentyString,"missing word THEN before it");
m_ierror++;
break;
}
pIdentyString=m_pScanner->ReadWord(pName,dwIdentyId,m_icLine);
if(dwIdentyId==WORD_ENDOFLINE||dwIdentyId==WORD_ENDOFFILE||!strcmp(pIdentyString,"//")){
//START IF ELSE ENDIF
dwIdenty=WORD_MTHEN;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
IF_ELSE_ENDIF * pIf=new IF_ELSE_ENDIF;
pIf->dwElseLbs=NewLabel();
pIf->dwEndLbs=NewLabel();
m_LineCode.Add(pIf->dwElseLbs);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
m_Cmpl.pushif(pIf);
}
else {
m_LineCode.Add(dwIdenty);
return ReadLine(FALSE,pIdentyString,dwIdentyId);
}
}
break;
case WORD_ELSE:
{
DWORD dwPos=m_Cmpl.GetElse();
if(dwPos==0xffffffff){
WriteError(pName,m_icLine,pIdentyString,"error define else,perhaps lost define if clause");
m_ierror++;
break;
}
SetLabelLine(dwPos,m_LineList.GetSize()+1);
dwPos=m_Cmpl.GetEndif();
if(dwPos==0xffffffff){
WriteError(pName,m_icLine,pIdentyString,"error define else,perhaps lost define if clause,compile stack error");
m_ierror++;
break;
}
dwIdenty=WORD_GOTO;
m_LineCode.Add(dwIdenty);
m_LineCode.Add(dwPos);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
}
break;
case WORD_ENDIF:
{
BOOL bLost;
IF_ELSE_ENDIF * pIf=m_Cmpl.popif(bLost);
if(!pIf){
WriteError(pName,m_icLine,pIdentyString,"error define endif,lost if define");
m_ierror++;
break;
}
if(!bLost){
delete pIf;
WriteError(pName,m_icLine,pIdentyString,"error define endif,lost other scope define such as endswitch or endwhile");
m_ierror++;
break;
}
SetLabelLine(pIf->dwEndLbs,m_LineList.GetSize()+1);
LABELSTRUCT * plbs=GetLabel(pIf->dwElseLbs);
ASSERT(plbs);
if(plbs->dwLabelId==0xffffffff){
plbs->dwLabelId=m_LineList.GetSize()+1;
}
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
delete pIf;
}
break;
case WORD_WHILE:
{
if(m_mypos.istype==TYPE_PUBLIC_POS){
WriteError(pName,m_icLine,pIdentyString,"error command in public erea");
m_ierror++;
break;
}
m_LineCode.Add(dwIdenty);
DWORD dwExpr;
pIdentyString=NULL;
if(!ExpressionRead(pIdentyString,dwIdentyId,dwIdenty,dwExpr)){
WriteError(pName,m_icLine,pIdentyString,"error cexpression");
m_ierror++;
break;
}
m_LineCode.Add(dwExpr);
if(dwIdenty!=WORD_THEN){
WriteError(pName,m_icLine,pIdentyString,"missing word THEN before it");
m_ierror++;
break;
}
dwIdenty=WORD_MTHEN;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
WHILE_THEN * pIf=new WHILE_THEN;
pIf->dwStartLbs=NewLabel(m_LineList.GetSize());
pIf->dwEndLbs=NewLabel();
m_LineCode.Add(pIf->dwEndLbs);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
m_Cmpl.pushwhile(pIf);
}
break;
case WORD_ENDWHILE:
{
BOOL bLost;
WHILE_THEN * pIf=m_Cmpl.popwhile(bLost);
if(!pIf){
WriteError(pName,m_icLine,pIdentyString,"error define endwhile,lost while define");
m_ierror++;
break;
}
if(!bLost){
delete pIf;
WriteError(pName,m_icLine,pIdentyString,"error define endif,lost other scope define such as endswitch or endif");
m_ierror++;
break;
}
SetLabelLine(pIf->dwEndLbs,m_LineList.GetSize()+1);
dwIdenty=WORD_GOTO;
m_LineCode.Add(dwIdenty);
m_LineCode.Add(pIf->dwStartLbs);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
delete pIf;
}
break;
case WORD_SWITCH:
{
if(m_mypos.istype==TYPE_PUBLIC_POS){
WriteError(pName,m_icLine,pIdentyString,"error command in public erea");
m_ierror++;
break;
}
m_LineCode.Add(dwIdenty);
DWORD dwExpr;
pIdentyString=NULL;
if(!ExpressionRead(pIdentyString,dwIdentyId,dwIdenty,dwExpr)){
WriteError(pName,m_icLine,pIdentyString,"error cexpression");
m_ierror++;
break;
}
m_LineCode.Add(dwExpr);
if(dwIdenty!=WORD_THEN){
WriteError(pName,m_icLine,pIdentyString,"missing word THEN before it");
m_ierror++;
break;
}
dwIdenty=WORD_MTHEN;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
SWITCH_CASE * pIf=new SWITCH_CASE;
pIf->dwExprTestLbs=NewLabel();
pIf->pCaseInfo=NULL;
pIf->dwEndLbs=NewLabel();
m_LineCode.Add(pIf->dwExprTestLbs);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
pIf->iNumOfCase=0;
m_Cmpl.pushswitch(pIf);
}
break;
case WORD_CASE:
{
CASE_INFO stkCaseInfo,* pstkCaseInfo;
pIdentyString=NULL;
if(!ExpressionRead(pIdentyString,dwIdentyId,dwIdenty,stkCaseInfo.dwExprId)){
WriteError(pName,m_icLine,pIdentyString,"error cexpression");
m_ierror++;
break;
}
stkCaseInfo.dwEntryLbs=NewLabel(m_LineList.GetSize()+1);
SWITCH_CASE * pIf=m_Cmpl.GetSwitch();
if(!pIf){
WriteError(pName,m_icLine,pIdentyString,"error define endswitch,lost switch define");
m_ierror++;
break;
}
pstkCaseInfo=pIf->pCaseInfo;
pIf->pCaseInfo=new CASE_INFO[pIf->iNumOfCase+1];
pIf->pCaseInfo[pIf->iNumOfCase]=stkCaseInfo;
if(pIf->iNumOfCase){
memcpy(pIf->pCaseInfo,pstkCaseInfo,pIf->iNumOfCase*sizeof(CASE_INFO));
delete [] pstkCaseInfo;
}
pIf->iNumOfCase++;
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
}
break;
case WORD_DEFAULT:
{
CASE_INFO stkCaseInfo,* pstkCaseInfo;
stkCaseInfo.dwExprId=WORD_DEFAULT;
stkCaseInfo.dwEntryLbs=NewLabel(m_LineList.GetSize()+1);
SWITCH_CASE * pIf=m_Cmpl.GetSwitch();
if(!pIf){
WriteError(pName,m_icLine,pIdentyString,"error define endswitch,lost switch define");
m_ierror++;
break;
}
pstkCaseInfo=pIf->pCaseInfo;
pIf->pCaseInfo=new CASE_INFO[pIf->iNumOfCase+1];
pIf->pCaseInfo[pIf->iNumOfCase]=stkCaseInfo;
if(pIf->iNumOfCase){
memcpy(pIf->pCaseInfo,pstkCaseInfo,pIf->iNumOfCase*sizeof(CASE_INFO));
delete [] pstkCaseInfo;
}
pIf->iNumOfCase++;
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
}
break;
case WORD_ENDSWITCH:
{
BOOL bLost;
SWITCH_CASE * pIf=m_Cmpl.popswitch(bLost);
if(!pIf){
WriteError(pName,m_icLine,pIdentyString,"error define endswitch,lost switch define");
m_ierror++;
break;
}
if(!bLost){
if(pIf->pCaseInfo)
delete [] pIf->pCaseInfo;
delete pIf;
WriteError(pName,m_icLine,pIdentyString,"error define endswitch,lost other scope define such as endif or endwhile");
m_ierror++;
break;
}
SetLabelLine(pIf->dwEndLbs,m_LineList.GetSize()+1);
DWORD dwLbs=NewLabel(pIf->dwEndLbs,pIf->iNumOfCase);
SetLabelLine(pIf->dwExprTestLbs,dwLbs);
for(int i=0;i<pIf->iNumOfCase;i++){
NewLabel(pIf->pCaseInfo[i].dwExprId,pIf->pCaseInfo[i].dwEntryLbs);
}
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
if(pIf->pCaseInfo)
delete [] pIf->pCaseInfo;
delete pIf;
}
break;
case WORD_CONTINUE:
{
DWORD dwPos=m_Cmpl.GetContinue();
if(dwPos==0xffffffff){
WriteError(pName,m_icLine,pIdentyString,"error define continue,perhaps lost define whilw clause");
m_ierror++;
break;
}
dwIdenty=WORD_GOTO;
m_LineCode.Add(dwIdenty);
m_LineCode.Add(dwPos);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
}
break;
case WORD_BREAK:
{
DWORD dwPos=m_Cmpl.GetBreak();
if(dwPos==0xffffffff){
WriteError(pName,m_icLine,pIdentyString,"error define break;perhaps lost define while/switch clause");
m_ierror++;
break;
}
dwIdenty=WORD_GOTO;
m_LineCode.Add(dwIdenty);
m_LineCode.Add(dwPos);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
}
break;
case WORD_RESET:
case WORD_BACK:
m_LineCode.Add(dwIdenty);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
break;
default:
WriteError(pName,m_icLine,pIdentyString,"unknown words");
m_ierror++;
break;
};
break;
case TYPE_FUNCTION:
{
if(m_ListFunction.GetSize()<=(int)(dwIdenty&POSID_FILTER)){
WriteError(pName,m_icLine,pIdentyString,"unknown errors");
m_ierror++;
break;
}
USERFUCTION & ufn=m_ListFunction[dwIdenty&POSID_FILTER];
if(ufn.ParamNum==0){
m_LineCode.Add(dwIdenty);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
}
else {
m_LineCode.Add(dwIdenty);
pIdentyString=NULL;
DWORD dwExpr=0;
for(int j=0;j<ufn.ParamNum;j++){
if(m_ParamArray[ufn.iStartParam+j].lpstrPreFix){
if(!pIdentyString)
pIdentyString=m_pScanner->ReadWord(pName,dwIdentyId,m_icLine);
if(strcmp(pIdentyString,m_ParamArray[ufn.iStartParam+j].lpstrPreFix)){
if(m_ParamArray[ufn.iStartParam+j].tv.btmust){
WriteError(pName,m_icLine,m_ParamArray[ufn.iStartParam+j].lpstrPreFix,"lost param item");
m_ierror++;
break;
}
else {
CString cs;
if(m_ParamArray[ufn.iStartParam+j].tv.it==DATA_TYPE_INT){
cs.Format("%ld",(int)m_ParamArray[ufn.iStartParam+j].tv);
GetPositionId((LPCTSTR)cs,dwExpr,WORD_UINT);
m_LineCode.Add(dwExpr);
}
else if(m_ParamArray[ufn.iStartParam+j].tv.it==DATA_TYPE_FLOAT){
cs.Format("%f",(double)m_ParamArray[ufn.iStartParam+j].tv);
GetPositionId((LPCTSTR)cs,dwExpr,WORD_FLOAT);
m_LineCode.Add(dwExpr);
}
else if(m_ParamArray[ufn.iStartParam+j].tv.it==DATA_TYPE_DWORD){
cs.Format("%lx",(DWORD)m_ParamArray[ufn.iStartParam+j].tv);
GetPositionId((LPCTSTR)cs,dwExpr,WORD_UINT);
m_LineCode.Add(dwExpr);
}
else if(m_ParamArray[ufn.iStartParam+j].tv.it==DATA_TYPE_STRING){
cs.Format("%s",(char *)m_ParamArray[ufn.iStartParam+j].tv);
GetPositionId((LPCTSTR)cs,dwExpr,WORD_STRING);
m_LineCode.Add(dwExpr);
}
else {
WriteError(pName,m_icLine,m_ParamArray[ufn.iStartParam+j].lpstrPreFix,"omit param item");
m_ierror++;
break;
}
}
continue;
}
else {
pIdentyString=NULL;
}
}
if(!ExpressionRead(pIdentyString,dwIdentyId,dwIdenty,dwExpr)){
WriteError(pName,m_icLine,pIdentyString,"error expression or identy");
m_ierror++;
break;
}
m_LineCode.Add(dwExpr);
if(dwIdentyId==WORD_COMMA){
pIdentyString=NULL;
}
}
if(j>=ufn.ParamNum){
if(dwIdentyId!=WORD_ENDOFLINE&&dwIdentyId!=WORD_ENDOFFILE){
if(!pIdentyString||strncmp(pIdentyString,"//",2)){
WriteError(pName,m_icLine,pIdentyString,"error cexpression");
m_ierror++;
break;
}
}
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
}
}
}
break;
case TYPE_COMMAND:
{
if(m_mypos.istype==TYPE_PUBLIC_POS){
WriteError(pName,m_icLine,pIdentyString,"error command in public erea");
m_ierror++;
break;
}
COMMANDSTRUCT * pcmd=&m_pStyle->m_CommandList[dwIdenty&POSID_FILTER];
if(pcmd->ParamNum<=0){
m_LineCode.Add(dwIdenty);
dwIdenty=WORD_ENDOFLINE;
m_LineCode.Add(dwIdenty);
bAddLineCode=TRUE;
}
else {
m_LineCode.Add(dwIdenty);
pIdentyString=NULL;
DWORD dwExpr=0;
for(int j=0;j<pcmd->ParamNum;j++){
if(m_pStyle->m_ParamArray[pcmd->iStartParam+j].lpstrPreFix){
if(!pIdentyString)
pIdentyString=m_pScanner->ReadWord(pName,dwIdentyId,m_icLine);
if(!strcmp(m_pStyle->m_ParamArray[pcmd->iStartParam+j].lpstrPreFix,"...")){
while(ExpressionRead(pIdentyString,dwIdentyId,dwIdenty,dwExpr)){
m_LineCode.Add(dwExpr);
if(dwIdentyId==WORD_COMMA){
pIdentyString=NULL;
}
}
if(dwIdentyId==WORD_ENDOFLINE||dwIdentyId==WORD_ENDOFFILE||!strcmp(pIdentyString,"//")){
j=pcmd->ParamNum;
}
else {
j=0;
WriteError(pName,m_icLine,pIdentyString,"error word in command line ");
m_ierror++;
}
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -