SOLVER_StateT Solver::countSAT() { retStateT state = RESOLVED; while (true) { while (component_analyzer_.findNextRemainingComponentOf(stack_.top())) { decideLiteral(); if (stopwatch_.timeBoundBroken()) return TIMEOUT; if (stopwatch_.interval_tick()) printOnlineStats(); while (!bcp()) { state = resolveConflict(); if (state == BACKTRACK) break; } if (state == BACKTRACK) break; } state = backtrack(); if (state == EXIT) return SUCCESS; while (state != PROCESS_COMPONENT && !bcp()) { state = resolveConflict(); if (state == BACKTRACK) { state = backtrack(); if (state == EXIT) return SUCCESS; } } } return SUCCESS; }
void ModelValidationHelper::applyFixes(void) { if(fix_mode) { bool validate_rels=false; while(!val_infos.empty() && !valid_canceled) { for(unsigned i=0; i < val_infos.size() && !valid_canceled; i++) { validate_rels=(val_infos[i].getValidationType()==ValidationInfo::BROKEN_REFERENCE || val_infos[i].getValidationType()==ValidationInfo::NO_UNIQUE_NAME); resolveConflict(val_infos[i]); } emit s_fixApplied(); validateModel(); sleepThread(5); } if(!valid_canceled && val_infos.empty()) { if(validate_rels) db_model->validateRelationships(); fix_mode=false; } } }
void ConflictDialog::open() { if( m_mergeItem == 0 ) { return; } switch( m_resolveAction ) { case ConflictDialog::AskUser: prepareLayout(); QDialog::open(); break; case ConflictDialog::PreferLocal: m_mergeItem->setResolution( MergeItem::A ); emit resolveConflict( m_mergeItem ); break; case ConflictDialog::PreferCloud: m_mergeItem->setResolution( MergeItem::B ); emit resolveConflict( m_mergeItem ); break; } }
void ConflictDialog::resolveConflict( QAbstractButton *button ) { accept(); QDialogButtonBox::StandardButton standardButton = m_box->standardButton( button ); switch(standardButton) { case QDialogButtonBox::NoButton: { int actionRole = button->property( "ActionRole" ).toInt(); switch( actionRole ) { case ConflictDialog::Local: m_mergeItem->setResolution( MergeItem::A ); emit resolveConflict( m_mergeItem ); break; case ConflictDialog::Cloud: m_mergeItem->setResolution( MergeItem::B ); emit resolveConflict( m_mergeItem ); break; case ConflictDialog::AllLocal: m_mergeItem->setResolution( MergeItem::A ); m_resolveAction = ConflictDialog::PreferLocal; emit resolveConflict( m_mergeItem ); break; case ConflictDialog::AllCloud: m_mergeItem->setResolution( MergeItem::B ); m_resolveAction = ConflictDialog::PreferCloud; emit resolveConflict( m_mergeItem ); break; default: break; } } default: break; } }
void Grammar::findActions( void ) { size_t i, j, nState, nSym, nRule; State *stp; nState = StateTable::get()->getNumStates(); nSym = SymbolTable::get()->getNumSymbols(); // Find all reduce actions... for ( i = 0; i < nState; ++i ) { stp = StateTable::get()->getNthState( i ); for ( Config *cfp = stp->getConfig(); cfp; cfp = cfp->getNext() ) { // Check if dot at extreme right if ( size_t( cfp->getDot() ) == cfp->getRule()->getRHS().size() ) { for ( j = 0; j < nSym; ++j ) { Symbol *sp = SymbolTable::get()->getNthSymbol( j ); if ( ( Symbol::TERMINAL == sp->getType() || sp->getName() == "$" ) && cfp->getFollowSet().isSet( sp->getName() ) ) { stp->addAction( Action::REDUCE, sp->getName(), 0, cfp->getRule() ); } } } } } Symbol *startSym = getStartSymbol(); stp = StateTable::get()->getNthState( 0 ); // Add the accepting token to the first state which is always the // starting state of the finite state machine as an action to accept // if the lookahead is the start nonterminal. if ( startSym && stp ) stp->addAction( Action::ACCEPT, startSym->getName(), 0, 0 ); // Resolve conflicts for ( i = 0; i < nState; ++i ) { stp = StateTable::get()->getNthState( i ); // Check for SHIFT-SHIFT conflicts first (nothing we can do to resolve) for ( Config *cfp = stp->getConfig(); cfp; cfp = cfp->getNext() ) { if ( ! cfp->getForwardPropLinks().empty() ) continue; Rule *curRule = cfp->getRule(); if ( size_t( cfp->getDot() ) == curRule->getRHS().size() ) continue; for ( Config *next = stp->getConfig(); next; next = next->getNext() ) { if ( next == cfp ) continue; Rule *nextRule = next->getRule(); if ( size_t( next->getDot() ) == nextRule->getRHS().size() ) continue; if ( curRule->getRHS()[cfp->getDot()].first == nextRule->getRHS()[next->getDot()].first ) { std::cout << "Unresolved SHIFT-SHIFT conflict between:\n" << std::endl; curRule->print( std::cout ); std::cout << std::endl << "\nand\n" << std::endl; nextRule->print( std::cout ); std::cout << std::endl << std::endl; ++myNumConflicts; } } } stp->sortActions(); ActionList &ap = stp->getActions(); size_t nAct = ap.getNumActions(); if ( nAct > 0 ) { for ( j = 0; j < (nAct - 1); ++j ) { Action &act = ap.getNthAction( j ); for ( size_t k = j + 1; k < nAct; ++k ) { Action &nact = ap.getNthAction( k ); int numCs = resolveConflict( act, nact ); if ( 0 != numCs ) { std::cout << " Conflict in state " << i << std::endl; myNumConflicts += numCs; } } } } } // Report errors for each rule that can never be reduced. nRule = RuleTable::get()->getNumRules(); for ( i = 0; i < nRule; ++i ) RuleTable::get()->getNthRule( i )->setCanReduce( false ); for ( i = 0; i < nState; ++i ) { stp = StateTable::get()->getNthState( i ); ActionList &ap = stp->getActions(); size_t nAct = ap.getNumActions(); for ( j = 0; j < nAct; ++j ) { Action &act = ap.getNthAction( j ); if ( act.getType() == Action::REDUCE ) act.getRule()->setCanReduce( true ); } } for ( i = 0; i < nRule; ++i ) { Rule *rp = RuleTable::get()->getNthRule( i ); if ( rp->canReduce() ) continue; std::ostringstream tmpOut; rp->print( tmpOut ); Error::get()->add( rp->getRuleLine(), "Rule for '%s':\n %s\ncan not be reduced.\n", rp->getLHS().c_str(), tmpOut.str().c_str() ); } }