📄 mal_parser.c
字号:
l= idLength(cntxt); if( l==0) { parseError(cntxt,"<identifier> expected\n"); pushInstruction(curBlk,curInstr); return; } #line 1354 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx"if ((varid = findVariableLength(curBlk, CURRENT(cntxt), l)) == -1){ arg = idCopy(cntxt,l); varid = newVariable(curBlk,arg,TYPE_any);} else advance(cntxt,l); #line 1389 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( currChar(cntxt)==':') { freezeVarType(curBlk,varid); type = typeElm(cntxt,getVarType(curBlk,varid)); setPolymorphic(curInstr, type, FALSE); setVarType(curBlk,varid,type); } #line 1127 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( keyphrase1(cntxt,"{")) { do { str pname,opname; int i,lo; ValRecord cst; l = idLength(cntxt); if(l==0) break; pname= idCopy(cntxt,l); if( curBlk->var[varid]->props== NULL) curBlk->var[varid]->props= newPropertySet(); /* localize value , simplified version */ lo= operatorLength(cntxt); if( lo > 0) opname= operatorCopy(cntxt,lo); else opname= GDKstrdup(""); if((i= cstToken(cntxt,&cst))){ setVarProperty(curBlk,varid, pname, opname, &cst); advance(cntxt,i); } else setVarProperty(curBlk,varid, pname, NULL, NULL); GDKfree(pname); GDKfree(opname); } while( keyphrase1(cntxt,",")); if( !keyphrase1(cntxt,"}") ) /* return (MalBlkPtr) */ parseError(cntxt,"'}' expected\n"); }#line 1396 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" curInstr= pushArgument(curBlk,curInstr, varid); curInstr->retc++; if( currChar(cntxt) == ')') break; if( currChar(cntxt) == ',') keyphrase1(cntxt,","); } advance(cntxt,1); /* skip ')' */ } else { /* are we dealing with a simple assignment? */ l= idLength(cntxt); if( l==0){ /* we haven't seen a target variable */ /* flow of control statements may end here. */ /* shouldn;t allow for nameless controls todo*/ if( cntrl == LEAVEsymbol || cntrl == REDOsymbol || cntrl == RETURNsymbol || cntrl == EXITsymbol ){ curInstr->argv[0]= getBarrierEnvelop(curBlk); pushInstruction(curBlk,curInstr); if( currChar(cntxt) != ';') parseError(cntxt,"<identifier> expected\n"); skipToEnd(cntxt); return; } getArg(curInstr,0)= newTmpVariable(curBlk,TYPE_any); pushInstruction(curBlk,curInstr); parseError(cntxt,"<identifier> expected\n"); return; } /* Check if we are dealing with module.fcn call*/ if( CURRENT(cntxt)[l]=='.' || CURRENT(cntxt)[l]=='(') { curInstr->argv[0]= newTmpVariable(curBlk,TYPE_any); goto FCNcallparse; } /* Get target variable details*/ #line 1354 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx"if ((varid = findVariableLength(curBlk, CURRENT(cntxt), l)) == -1){ arg = idCopy(cntxt,l); varid = newVariable(curBlk,arg,TYPE_any);} else advance(cntxt,l); #line 1433 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( !(currChar(cntxt)==':' && CURRENT(cntxt)[1]=='=') ){ if( currChar(cntxt)==':') { freezeVarType(curBlk,varid); type = typeElm(cntxt,getVarType(curBlk,varid)); setPolymorphic(curInstr, type, FALSE); setVarType(curBlk,varid,type); } } #line 1127 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( keyphrase1(cntxt,"{")) { do { str pname,opname; int i,lo; ValRecord cst; l = idLength(cntxt); if(l==0) break; pname= idCopy(cntxt,l); if( curBlk->var[varid]->props== NULL) curBlk->var[varid]->props= newPropertySet(); /* localize value , simplified version */ lo= operatorLength(cntxt); if( lo > 0) opname= operatorCopy(cntxt,lo); else opname= GDKstrdup(""); if((i= cstToken(cntxt,&cst))){ setVarProperty(curBlk,varid, pname, opname, &cst); advance(cntxt,i); } else setVarProperty(curBlk,varid, pname, NULL, NULL); GDKfree(pname); GDKfree(opname); } while( keyphrase1(cntxt,",")); if( !keyphrase1(cntxt,"}") ) /* return (MalBlkPtr) */ parseError(cntxt,"'}' expected\n"); }#line 1442 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" curInstr->argv[0]= varid; } /* look for assignment operator */ if( !keyphrase2(cntxt,":=") ){ /* no assignment !! a control variable is allowed */ if (currChar(cntxt) != ';') parseError(cntxt,"';' expected\n"); goto part3; } if (currChar(cntxt) == '('){ /* parse multi assignment */ advance(cntxt,1); #line 1528 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx"while( currChar(cntxt)!= ')'){ #line 1466 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" str v = NULL; if( (i= cstToken(cntxt,&cst))){ int cstidx = -1,csttpe= TYPE_any; cstidx = fndConstant(curBlk,&cst); if( cstidx >= 0){ advance(cntxt,i); if( currChar(cntxt)==':') { csttpe = typeElm(cntxt,getVarType(curBlk,cstidx)); if(csttpe == getVarType(curBlk,cstidx) ){ freezeVarType(curBlk,cstidx); } else { cstidx = defConstant(curBlk,csttpe,&cst); setPolymorphic(curInstr,csttpe, FALSE); freezeVarType(curBlk,cstidx); } } else if( cst.vtype != getVarType(curBlk,cstidx)){ cstidx = defConstant(curBlk,cst.vtype,&cst); setPolymorphic(curInstr,cst.vtype, FALSE); } curInstr = pushArgument(curBlk,curInstr,cstidx); ; } else { /* add a new constant */ int flag; advance(cntxt,i); flag= currChar(cntxt)==':'; csttpe = typeElm(cntxt,cst.vtype); cstidx = defConstant(curBlk,csttpe,&cst); setPolymorphic(curInstr,csttpe, FALSE); if( flag ) freezeVarType(curBlk,cstidx); curInstr = pushArgument(curBlk,curInstr,cstidx); ; } } else if( (i= idLength(cntxt))){ if( (idx=findVariableLength(curBlk,CURRENT(cntxt),i)) == -1){ v= idCopy(cntxt,i); i= typeElm(cntxt,TYPE_any); setPolymorphic(curInstr,i, FALSE); idx = newVariable(curBlk, v, i); #line 1127 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( keyphrase1(cntxt,"{")) { do { str pname,opname; int i,lo; ValRecord cst; l = idLength(cntxt); if(l==0) break; pname= idCopy(cntxt,l); if( curBlk->var[idx]->props== NULL) curBlk->var[idx]->props= newPropertySet(); /* localize value , simplified version */ lo= operatorLength(cntxt); if( lo > 0) opname= operatorCopy(cntxt,lo); else opname= GDKstrdup(""); if((i= cstToken(cntxt,&cst))){ setVarProperty(curBlk,idx, pname, opname, &cst); advance(cntxt,i); } else setVarProperty(curBlk,idx, pname, NULL, NULL); GDKfree(pname); GDKfree(opname); } while( keyphrase1(cntxt,",")); if( !keyphrase1(cntxt,"}") ) /* return (MalBlkPtr) */ parseError(cntxt,"'}' expected\n"); }#line 1509 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" } else { advance(cntxt,i); i = typeElm(cntxt,getVarType(curBlk,idx)); setPolymorphic(curInstr,i,FALSE); #line 1127 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( keyphrase1(cntxt,"{")) { do { str pname,opname; int i,lo; ValRecord cst; l = idLength(cntxt); if(l==0) break; pname= idCopy(cntxt,l); if( curBlk->var[idx]->props== NULL) curBlk->var[idx]->props= newPropertySet(); /* localize value , simplified version */ lo= operatorLength(cntxt); if( lo > 0) opname= operatorCopy(cntxt,lo); else opname= GDKstrdup(""); if((i= cstToken(cntxt,&cst))){ setVarProperty(curBlk,idx, pname, opname, &cst); advance(cntxt,i); } else setVarProperty(curBlk,idx, pname, NULL, NULL); GDKfree(pname); GDKfree(opname); } while( keyphrase1(cntxt,",")); if( !keyphrase1(cntxt,"}") ) /* return (MalBlkPtr) */ parseError(cntxt,"'}' expected\n"); }#line 1514 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" } curInstr= pushArgument(curBlk,curInstr,idx); } else if (currChar(cntxt) == ':'){ i = typeElm(cntxt,TYPE_any); setPolymorphic(curInstr,i,FALSE); idx = newTypeVariable(curBlk, i ); #line 1127 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( keyphrase1(cntxt,"{")) { do { str pname,opname; int i,lo; ValRecord cst; l = idLength(cntxt); if(l==0) break; pname= idCopy(cntxt,l); if( curBlk->var[idx]->props== NULL) curBlk->var[idx]->props= newPropertySet(); /* localize value , simplified version */ lo= operatorLength(cntxt); if( lo > 0) opname= operatorCopy(cntxt,lo); else opname= GDKstrdup(""); if((i= cstToken(cntxt,&cst))){ setVarProperty(curBlk,idx, pname, opname, &cst); advance(cntxt,i); } else setVarProperty(curBlk,idx, pname, NULL, NULL); GDKfree(pname); GDKfree(opname); } while( keyphrase1(cntxt,",")); if( !keyphrase1(cntxt,"}") ) /* return (MalBlkPtr) */ parseError(cntxt,"'}' expected\n"); }#line 1521 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" curInstr = pushArgument(curBlk,curInstr,idx); ; }#line 1529 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" else { idx = 0; parseError(cntxt,"<factor> expected\n"); pushInstruction(curBlk,curInstr); return ; } if (currChar(cntxt) == ',') advance(cntxt,1); else if (currChar(cntxt) != ')') { parseError(cntxt,"',' expected\n"); cntxt->yycur--; /* keep it */ break; }}if (currChar(cntxt) == ')') advance(cntxt,1);#line 1455 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" /* parseAssign() -> void */ skipToEnd(cntxt); pushInstruction(curBlk,curInstr); return; }#line 1551 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx"FCNcallparse: if( (l=idLength(cntxt)) && CURRENT(cntxt)[l] == '(') { setModuleId(curInstr,putName("user",4)); i= l; goto FCNcallparse2; } else if( (l=idLength(cntxt)) && CURRENT(cntxt)[l] == '.') { /* continue with parseing a function/operator call */ arg= putName(CURRENT(cntxt),l); advance(cntxt,l+1); /* skip '.' too */ setModuleId(curInstr,arg); i = idLength(cntxt); if( i==0) i= operatorLength(cntxt);FCNcallparse2: if( i ) { setFunctionId(curInstr, putName(((char*)CURRENT(cntxt)),i)); advance(cntxt,i); } else { parseError(cntxt,"<functionname> expected\n"); pushInstruction(curBlk,curInstr); return; } skipSpace(cntxt); if (currChar(cntxt) != '(') { parseError(cntxt,"'(' expected\n"); pushInstruction(curBlk,curInstr); return; } advance(cntxt,1); #line 1528 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx"while( currChar(cntxt)!= ')'){ #line 1466 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" str v = NULL; if( (i= cstToken(cntxt,&cst))){ int cstidx = -1,csttpe= TYPE_any; cstidx = fndConstant(curBlk,&cst); if( cstidx >= 0){ advance(cntxt,i); if( currChar(cntxt)==':') { csttpe = typeElm(cntxt,getVarType(curBlk,cstidx)); if(csttpe == getVarType(curBlk,cstidx) ){ freezeVarType(curBlk,cstidx); } else { cstidx = defConstant(curBlk,csttpe,&cst); setPolymorphic(curInstr,csttpe, FALSE); freezeVarType(curBlk,cstidx); } } else if( cst.vtype != getVarType(curBlk,cstidx)){ cstidx = defConstant(curBlk,cst.vtype,&cst); setPolymorphic(curInstr,cst.vtype, FALSE); } curInstr = pushArgument(curBlk,curInstr,cstidx); ; } else { /* add a new constant */ int flag; advance(cntxt,i); flag= currChar(cntxt)==':'; csttpe = typeElm(cntxt,cst.vtype); cstidx = defConstant(curBlk,csttpe,&cst); setPolymorphic(curInstr,csttpe, FALSE); if( flag ) freezeVarType(curBlk,cstidx); curInstr = pushArgument(curBlk,curInstr,cstidx); ; } } else if( (i= idLength(cntxt))){ if( (idx=findVariableLength(curBlk,CURRENT(cntxt),i)) == -1){ v= idCopy(cntxt,i); i= typeElm(cntxt,TYPE_any); setPolymorphic(curInstr,i, FALSE); idx = newVariable(curBlk, v, i); #line 1127 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( keyphrase1(cntxt,"{")) { do { str pname,opname; int i,lo; ValRecord cst; l = idLength(cntxt); if(l==0) break; pname= idCopy(cntxt,l); if( curBlk->var[idx]->props== NULL) curBlk->var[idx]->props= newPropertySet(); /* localize value , simplified version */ lo= operatorLength(cntxt); if( lo > 0) opname= operatorCopy(cntxt,lo); else opname= GDKstrdup(""); if((i= cstToken(cntxt,&cst))){ setVarProperty(curBlk,idx, pname, opname, &cst); advance(cntxt,i); } else setVarProperty(curBlk,idx, pname, NULL, NULL); GDKfree(pname); GDKfree(opname); } while( keyphrase1(cntxt,",")); if( !keyphrase1(cntxt,"}") ) /* return (MalBlkPtr) */ parseError(cntxt,"'}' expected\n"); }#line 1509 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" } else { advance(cntxt,i); i = typeElm(cntxt,getVarType(curBlk,idx)); setPolymorphic(curInstr,i,FALSE); #line 1127 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" if( keyphrase1(cntxt,"{")) { do { str pname,opname; int i,lo; ValRecord cst; l = idLength(cntxt); if(l==0) break; pname= idCopy(cntxt,l); if( curBlk->var[idx]->props== NULL) curBlk->var[idx]->props= newPropertySet(); /* localize value , simplified version */ lo= operatorLength(cntxt); if( lo > 0) opname= operatorCopy(cntxt,lo); else opname= GDKstrdup(""); if((i= cstToken(cntxt,&cst))){ setVarProperty(curBlk,idx, pname, opname, &cst); advance(cntxt,i); } else setVarProperty(curBlk,idx, pname, NULL, NULL); GDKfree(pname); GDKfree(opname); } while( keyphrase1(cntxt,",")); if( !keyphrase1(cntxt,"}") ) /* return (MalBlkPtr) */ parseError(cntxt,"'}' expected\n"); }#line 1514 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_parser.mx" } curInstr= pushArgument(cu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -