int params() { int enumerator; if ((error = testToken(T_ID)) != E_OK) return error; // "ID_parametru" - mozna specifikovat strInit(&IDstr); strCopystring(&IDstr, &T.s); gettoken(); if ((error = testToken(T_COLON)) != E_OK) return error; // ":" gettoken(); if ((error = testToken(T_DATATYPE)) != E_OK) return error; if(!(strCmpConstStr(&(T.s), "boolean"))) enumerator = O_BOOL; else if(!(strCmpConstStr(&(T.s), "integer"))) enumerator = O_INT; else if(!(strCmpConstStr(&(T.s), "real"))) enumerator = O_REAL; else if(!(strCmpConstStr(&(T.s), "string"))) enumerator = O_STRING; else return E_SEMA; gettoken(); pc++; if(strCmpstring(&IDstr, &ActFun) == 0) return E_SEMA; //ADDED if (searchParam(paramlist, &IDstr) != NULL) return E_SEMA; if ((error = insertParam(paramlist,&IDstr, enumerator)) != E_OK) return error;; //strFree(&IDstr); if (testToken(T_SEMICOLON) == E_OK) { gettoken(); if((error = params()) != E_OK) return error; //vice parametru - rekurze } return E_OK; }
void CFGManager::readGroup(const string &group, const YAML::Node ¶mNodes) { unsigned int i, j; string type = ""; cfgParamId newId = 0; for(i = 0; i < paramNodes.size(); ++i) { paramNodes[i]["type"] >> type; //cout << "Found type: " << type << endl; for(j = 0; j < dstNrOfParamTypes; ++j) { if( cfgParamTypeString[j] == type ) { break; } } // for CFGParam *param = NULL; switch (j) { case doubleParam : newId = getNextId(); param = CFGParamDouble::createParam(newId, group, paramNodes[i]); insertParam(param); break; case intParam : newId = getNextId(); param = CFGParamInt::createParam(newId, group, paramNodes[i]); insertParam(param); break; case boolParam : newId = getNextId(); param = CFGParamBool::createParam(newId, group, paramNodes[i]); insertParam(param); break; case stringParam : newId = getNextId(); param = CFGParamString::createParam(newId, group, paramNodes[i]); insertParam(param); break; default: // do nothing cout << "CFG: unknown type: " << type; } // switch if(newId != 0) { addedCFGParam(newId); newId = 0; } } // for }
cfgParamId CFGManager::createParam(const string &_group, const string &_name, const cfgParamType &_paramType) { if( (_group != "") && (_name != "") ) { cfgParamId newId; newId = getParamId(_group, _name); if( newId != 0 ) { return newId; } else { CFGParam *param = NULL; switch (_paramType) { case doubleParam : newId = getNextId(); param = (CFGParam*) (new CFGParamDouble(newId, _group, _name)); insertParam(param); break; case intParam : newId = getNextId(); param = (CFGParam*) (new CFGParamInt(newId, _group, _name)); insertParam(param); break; case boolParam : newId = getNextId(); param = (CFGParam*) (new CFGParamBool(newId, _group, _name)); insertParam(param); break; case stringParam : newId = getNextId(); param = (CFGParam*) (new CFGParamString(newId, _group, _name)); insertParam(param); break; default : newId = 0; } // switch if(newId != 0) { addedCFGParam(newId); } return newId; } } return 0; }
bool CParameter::OnKeyDown(wxKeyEvent& event) { switch( event.GetKeyCode() ) { case 'p': case 'P': insertParam(event.GetX(), event.GetY()); return true; case WXK_UP: case WXK_NUMPAD_UP: case '+': if(NULL != m_pSelectedPoint) m_pSelectedPoint->Move(0, -1); return true; case WXK_DOWN: case WXK_NUMPAD_DOWN: case '-': if(NULL != m_pSelectedPoint) m_pSelectedPoint->Move(0, 1); return true; case WXK_PRIOR: // case WXK_PAGEUP: case WXK_NUMPAD_PAGEUP: if(NULL != m_pSelectedPoint) m_pSelectedPoint->Move(-1, 0); return true; case WXK_NEXT: // case WXK_PAGEDOWN: case WXK_NUMPAD_PAGEDOWN: if(NULL != m_pSelectedPoint) m_pSelectedPoint->Move(1, 0); return true; case WXK_DELETE: if(NULL != m_pSelectedPoint) { if( m_pInput->ResetParamAt( m_pSelectedPoint->m_offset, m_index, m_pSelectedPoint->m_value) ) Refresh(); } break; default: break; } return false; }
bool CParameter::OnMouseEvent(wxMouseEvent& event) { bool bResult = false; if( event.LeftDown() ) { if( !IsSelected() ) Select(); // else // insertParam(event.GetX(), event.GetY()); bResult = true; } else if( event.MiddleDown() ) { insertParam(event.GetX(), event.GetY()); bResult = true; } IFloopyObj::OnMouseEvent(event); return bResult; }
//################### HLEDANI A ZPRACOVANI FUNKCE ####################### tErrors SearchFun() { tFunListItem *FunPtr; // ukazatel na prvek seznamu funkce tVariable *pTree; // ukazatel na strukturu tVariable tParamItem *param; // ukazatel na parametr tErrors er; // promenna typu tErrors pro ulozeni vysledneho error kodu tExpType type; // typ prvku na zasobniku tVariable *temp; tVariable *temp2; tParamList *parameterList; int param_counter = 0; int param_number = 0; parameterList = allocate(sizeof(tParamList)); initParamlist(parameterList); FunPtr = searchFunList(&(T.s)); // pokud najdes funkci v seznamu funkci param_number = FunPtr->param_count; // ulozeni - pocet parametru funkce do param param = FunPtr->param_list->first; // ulozeni ukazatele na prvni prvek v seznamu parametru funkci gettoken(); er = ConvertToken(&type); // konvertovani tokenu if (er) // pokud konvert neprobehl v poradku return E_SYN; // koncim s chybou if (type != LB) // pokud nenasleduje leva zavorka, E_SYN return E_SYN; gettoken(); er = ConvertToken(&type); // konvertovani tokenu if (er) // pokud konvert neprobehl v poradku return E_SYN; // koncim s chybou //printf("P: %d T.TYPE: %d\n",param_number,T.type); if ((param_number == 0) && (T.type != T_RB)) return E_SEMB; while((type != RB) && ((strCmpConstStr (&(T.s), "end")!=0) && (T.type != T_SEMICOLON))) // ber novy token dokud neprojdes vsechny parametry funkce { //printf("JSEM ve WHILE\n"); //printf("TOKEN 01: %s\n",T.s.str); if (T.type == T_ID) // pokud je typ ID, vyhledej jej v BVS { if (insertParam(parameterList, &(T.s), T.type) != E_OK) return E_INTERN; if ((SearchDataType(TempTree, TempTreeL)) != NULL) // pokud je token typu ID a je nalezen v BVS { pTree = SearchDataType(TempTree, TempTreeL); // uloz mi ukazatel na prvek do stromu if (pTree->type != param->type) // pokud neni typ tokenu roven typu parametru funkce return E_SEMB; // vraci E_SEMB } else { // pokud neni prvek nalezen return E_SEMA; // vraci E_SEMA } } else if (T.type == T_INT) { if (param->type != O_INT) // pokud neni typ tokenu roven typu parametru funkce return E_SEMB; } else if (T.type == T_REAL) { if (param->type != O_REAL) // pokud neni typ tokenu roven typu parametru funkce return E_SEMB; } else if (T.type == T_STRING) { if (param->type != O_STRING) // pokud neni typ tokenu roven typu parametru funkce return E_SEMB; } else if (T.type == T_KONST) { if (param->type != O_BOOL) // pokud neni typ tokenu roven typu parametru funkce return E_SEMB; } else // pokud neni parametr ID { return E_SYN; // vraci chybu E_SYN } gettoken(); er = ConvertToken(&type); // konvertovani tokenu if (er) // pokud konvert neprobehl v poradku return E_SYN; // koncim s chybou param_counter++; // pocitadlo paramateru if (((param_counter == param_number) && (type != RB)) && (type != COMMA)) // pokud neni za ID carka nebo za posledni parametrem neni prava zavorka return E_SYN; // vrat chybu E_SYN if (param_counter > param_number) // pokud pocitadlo parametru je vetsi jako hodnota, ktera je udana u funkce v seznamu return E_SEMB; // vrat chybu E_SEMB if (param->next != NULL) param = param->next; // posunuti na dalsi parametr funkce ??????????????????????? gettoken(); er = ConvertToken(&type); // konvertovani tokenu if (er) // pokud konvert neprobehl v poradku return E_SYN; // koncim s chybou } if (param_number != param_counter) return E_SEMB; res = FunPtr->ret_type; if ((temp = allocate(sizeof(tVariable))) == NULL) //pokud neni dostatek pameti => E_INTERN return E_INTERN; if (strInit(&(temp->name)) == STR_ERROR) //pokud funkce init. stringu vrati chybu => E_INTERN return E_INTERN; if ((temp2 = allocate(sizeof(tVariable))) == NULL) //pokud neni dostatek pameti => E_INTERN return E_INTERN; if (strInit(&(temp2->name)) == STR_ERROR) //pokud funkce init. stringu vrati chybu => E_INTERN return E_INTERN; temp->name = FunPtr->name; temp->value.param_pointer = parameterList->first; temp->type = PARAM_POINTER; temp2->type = TAPE_POINTER; temp2->value.tape_pointer = FunPtr->tape_ptr; Tape->last->op1 = temp; // ulozeni ukazatele na tVariable polozku, ktera obsahuje ukazatel na funkci na pasce Tape->last->instruction = CALL; // instrukce je funkce Tape->last->op2 = temp2; Tape->last->result->type = FunPtr->ret_type; if (param_counter == 0) gettoken(); return E_OK; // pokud to najde funkci E_OK }