void FormGenListBagComposition::updateInputWidgets() { if( mUpdating ) return; const int currentRow = selectionModel()->currentIndex().row(); const int rowCount = model()->rowCount(); if( ! isValueSet() || mElement == nullptr || currentRow < 0) { mUpdating = true; if( mElement ) mElement->setValidatedValue(mElement->defaultValue()); mHead->spinPosition->setValue(0); mUpdating = false; } else { mUpdating = true; mElement->setValidatedValue(model()->data(model()->index(currentRow, 0), Qt::EditRole)); mHead->spinPosition->setMaximum(rowCount - 1); mHead->spinPosition->setValue(currentRow); mUpdating = false; } if( ! isValueSet() || mElement == nullptr ) { mHeadWidget->setEnabled(false); if( mElementWrapper ) mElementWrapper->setEnabled(false); } else if( currentRow < 0 ) { mHeadWidget->setEnabled(true); mElementWrapper->setEnabled(false); mHead->buttonDelete->setEnabled(false); mHead->buttonClear->setEnabled(rowCount > 0); mHead->spinPosition->setEnabled(false); mHead->buttonCopy->setEnabled(false); } else { mHeadWidget->setEnabled(true); mElementWrapper->setEnabled(true); mHead->buttonDelete->setEnabled(true); mHead->buttonClear->setEnabled(true); mHead->spinPosition->setEnabled(true); mHead->buttonCopy->setEnabled(true); } }
void ZDriver::writeAcceptFuncDecl( std::ostream &out ) { const std::string &extraArg = getValue( "extra_argument" ).first; if ( isValueSet( "parse_accept" ) ) { if ( extraArg.empty() ) out << " void accept( void );" << endl(); else out << " void accept( " << extraArg << " );" << endl(); } }
void ZDriver::writeAcceptFunc( std::ostream &out ) { const std::string &extraArg = getValue( "extra_argument" ).first; if ( isValueSet( "parse_accept" ) ) { emitFuncBreak( out ); if ( extraArg.empty() ) out << "void " << myPimplName << "::accept( void )" << endl(); else out << "void " << myPimplName << "::accept( " << extraArg << " )" << endl(); out << "{" << endl(); emitValue( getValue( "parse_accept" ), out ); out << "}" << endl(); } }
void ZDriver::writeReduceFunc( std::ostream &out ) { size_t i, nRule; nRule = RuleTable::get()->getNumRules(); emitFuncBreak( out ); out << "void " << myPimplName << "::reduce( int ruleNum" << myExtraArg << " )" << endl(); out << "{" << endl(); if ( isDebugOutput() ) out << " std::cout << \"REDUCE rule \" << ruleNum << std::endl;" << endl(); out << " int newVal;" << endl(); out << " ParserAct next;" << endl(); out << " Util::Any data;" << endl(); out << " std::vector< Util::Any > rhsData;" << endl() << endl(); out << " rhsData.reserve( myRules[ruleNum].second );" << endl(); out << " for ( int i = 0, N = myRules[ruleNum].second; i != N; ++i )" << endl(); out << " {" << endl(); out << " if ( myStack.empty() )" << endl() << " rhsData.insert( rhsData.begin(), data );" << endl() << " else" << endl() << " {" << endl(); out << " rhsData.insert( rhsData.begin(), myStack.top().second );" << endl(); out << " myStack.pop();" << endl() << " }" << endl(); out << " }" << endl(); out << endl(); out << " next = findParserAction( newVal, myRules[ruleNum].first );" << endl(); out << endl(); out << " switch ( ruleNum )" << endl(); out << " {" << endl(); for ( i = 0; i < nRule; ++i ) { Rule *rp = RuleTable::get()->getNthRule( i ); out << " case " << i << ":" << endl(); out << " {" << endl(); out << " // "; rp->print( out ); out << endl(); emitRule( rp, out ); out << " break;" << endl(); out << " }" << endl() << endl(); } out << " default:" << endl(); out << " throw \"Unknown Rule Number\";" << endl(); out << " break;" << endl(); out << " }" << endl(); out << endl(); out << " if ( PA_SHIFT == next )" << endl(); out << " shift( newVal, myRules[ruleNum].first, data );" << endl(); if ( isValueSet( "parse_accept" ) ) { out << " else" << endl(); if ( !myExtraArgCall.empty() ) out << " accept( " << myExtraArgCall << " );" << endl(); else out << " accept();" << endl(); } out << "}" << endl(); }
void ZDriver::writeMainParserFunc( std::ostream &out ) { const std::string &tokenType = getValue( "token_type" ).first; const std::string &prefix = getValue( "token_prefix" ).first; emitFuncBreak( out ); out << "void " << myPimplName << "::parse( " << getParserName() << "::Terminal tok, "; if ( tokenType.empty() ) out << "void *"; else { out << tokenType; if ( *(tokenType.end() - 1) != '*' && *(tokenType.end() - 1) != '&' ) out << " "; } out << "value" << myExtraArg << " )" << endl(); out << "{" << endl(); out << " int actVal;" << endl(); out << " ParserAct action;" << endl(); out << " bool errHit = false;" << endl(); out << " bool eoInput = (tok == " << getParserName() << "::" << prefix << "EOF );" << endl(); out << " bool done = false;" << endl(); out << endl(); out << " if ( myStack.empty() )" << endl(); out << " {" << endl(); out << " if ( eoInput )" << endl(); out << " return;" << endl(); out << endl(); out << " myErrCount = -1;" << endl(); out << " }" << endl(); out << endl(); out << " Util::Any data( value );" << endl(); out << endl(); out << " do" << endl() << " {" << endl(); out << " action = findParserAction( actVal, tok );" << endl(); out << " if ( PA_SHIFT == action )" << endl(); out << " {" << endl(); out << " shift( actVal, tok, data );" << endl(); out << " --myErrCount;" << endl(); out << " if ( eoInput && ! myStack.empty() )" << endl(); out << " tok = " << getParserName() << "::" << prefix << "EOF;" << endl(); out << " else" << endl(); out << " done = true;" << endl(); out << " }" << endl(); out << " else if ( PA_REDUCE == action )" << endl(); out << " {" << endl(); if ( ! myExtraArgCall.empty() ) out << " reduce( actVal, " << myExtraArgCall << " );" << endl(); else out << " reduce( actVal );" << endl(); out << " }" << endl(); out << " else if ( PA_ERROR == action )" << endl(); out << " {" << endl(); emitErrorHandling( out ); out << " }" << endl(); out << " else // ACCEPT == action || NOP == action" << endl(); out << " {" << endl(); if ( isValueSet( "parse_accept" ) ) { if ( !myExtraArgCall.empty() ) out << " accept( " << myExtraArgCall << " );" << endl(); else out << " accept();" << endl(); } out << " done = true;" << endl(); out << " }" << endl(); out << " } while ( ! done && ! myStack.empty() );" << endl(); out << "}" << endl(); }