void InfixToPostfix::loadMathOperators() { addOperator("^"); addOperator("/ * %"); addOperator("sin cos tan sinh cosh tanh"); addOperator("+ -"); }
bool parserCls::factor(void) { EtokenType lTt1 = getTokenType();bool bb1 = true ; tokenContainCls lTc1 =getCurToken() ,lTc2;bool seeUnary= false; if( (lTt1 == Plus) || (lTt1==Minus) || (lTt1 == Not) ) { if(lTt1== Plus) lTc1.type = UnaryPlus; else if(lTt1== Minus) lTc1 . type = UnaryMinus; lTc2=lTc1;getToken();lTt1=getTokenType(); lTc1=getCurToken();seeUnary=true; } switch(lTt1){ case OrdNumber:case SciNumber:case Array : addOperand() ;exprFound = true ;needOperand = false ;getToken(); break ; case String : if(seeUnary) {errorUnary(lTc2 ,1);bb1 = false;break ;} addOperand();exprFound=true;needOperand=false ;getToken(); break ; case Name : exprFound = true ;needOperand=false;getToken(); if(getTokenType() == Lparen ) bb1=addFunction(lTc1); else addName(lTc1) ; break ; case Lparen :recursiveLparen() ;break ; case Rparen :if(seeUnary) {errorUnary(lTc2 , 2);bb1 = false ;break ;} break ; default :if(needOperand) errorFactor(); bb1 = false ; break ; } if(seeUnary && bb1) addOperator(lTc2); return bb1 ; }
//----------------------------------------------------------------------- void OperatorManager::applyOperator(Operator* op) { assert(op); op->redo(); addOperator(op); }
RTN_COORD_OP_END rtnCoordProcesserFactory::rtnCoordProcesserFactory() { addCommand(); addOperator(); }
Measurement::Measurement(MatrixXcd observable) { ComplexEigenSolver<MatrixXcd> solver(observable); MatrixXcd vectors = solver.eigenvectors(); for (int i = 0; i < vectors.cols(); ++i) addOperator(vectors.col(i) * vectors.col(i).transpose(), i_to_string(i)); _checkOperatorsAreValid(); }
Proector::Proector(HilbertSpace space) { for (int i = 0; i < space.totalDimension(); ++i) { VectorXi toLabel = space.getVector(i); VectorXcd op = space.getBasisVector(toLabel); addOperator(op * op.transpose(), _vecToLabel(toLabel)); } }
void Tptp::addTheory(Theory theory) { ExprManager * em = getExprManager(); switch(theory) { case THEORY_CORE: //TPTP (CNF and FOF) is unsorted so we define this common type { std::string d_unsorted_name = "$$unsorted"; d_unsorted = em->mkSort(d_unsorted_name); preemptCommand( new DeclareTypeCommand(d_unsorted_name, 0, d_unsorted) ); } // propositionnal defineType("Bool", em->booleanType()); defineVar("$true", em->mkConst(true)); defineVar("$false", em->mkConst(false)); addOperator(kind::AND); addOperator(kind::EQUAL); addOperator(kind::IMPLIES); //addOperator(kind::ITE); //only for tff thf addOperator(kind::NOT); addOperator(kind::OR); addOperator(kind::XOR); addOperator(kind::APPLY_UF); //Add quantifiers? break; default: std::stringstream ss; ss << "internal error: Tptp::addTheory(): unhandled theory " << theory; throw ParserException(ss.str()); } }
bool parserCls::term5(void) { bool s1 = term6();if(s1==false) return false ; EtokenType et1 = getTokenType();tokenContainCls t1 ; while( (et1== Mul )||(et1 == Div )|| (et1 == Mod)) { t1 =getCurToken();getToken();bool s2 = term6(); if(s2==false) return false ; addOperator(t1);et1 = getTokenType(); } return s1 ; }
bool parserCls::term6(void) { bool s1 = factor();if(s1==false) return false ; EtokenType et1 = getTokenType();tokenContainCls t1 ; if(et1== Pow) { t1 =getCurToken(); getToken(); bool s2 = factor(); if(s2==false) return false ; addOperator(t1); et1 = getTokenType(); } return s1 ; }
bool parserCls::term2(void) { bool s1 = term3();if(s1==false) return false ; EtokenType et1=getTokenType();tokenContainCls t1 ; if((et1==ExEq)||(et1==Ne)||(et1==Ge)||(et1==Le)|| (et1==Gt)||(et1==Lt)||(et1==Eq) ) { t1=getCurToken();getToken();bool s2 = term3(); if(s2==false) return false ; addOperator(t1);et1 = getTokenType(); } return s1 ; }
/// fa+b,c+d) /// f is the name of function // one error not checked f(a,,b) bool parserCls::addFunction(tokenContainCls &lTc1) { lTc1.type = FunctionName; addOperand(lTc1);bool bb2 = true ; bool bb3=false;EtokenType lt1;int iiExpr12=0,indexX=noTokenInExpr++; addOperand(lTc1); // for stack for change after end do{ if(bb3) addOperand(); else bb3 = true ; getToken();// get next token after ( if(!term1() ){ bb2 = false ;break ;} if((noTokenInExpr-2) > (indexX)) iiExpr12++; lt1= getTokenType(); }while((lt1==Comma)); if(bb2) if(lt1 != Rparen) {bb2 = false; errorRecursLparen(1, lTc1);} else {addOperator();getToken();} tokenContainCls lTc2(iiExpr12,1); addOperator(indexX, lTc2); return bb2 ; }
bool parserCls::term3(void) { bool s1 = term4();if(s1==false) return false ; EtokenType et1 = getTokenType();tokenContainCls t1 ; while( (et1== Concat ) ) { t1 =getCurToken();getToken();bool s2 = term4(); if(s2==false) return false ; addOperator(t1); et1 = getTokenType(); } return s1 ; }
void Expression::buildBytecodePostfix(OperationCode *opcode, Parser *parser) { for (list<ExpressionTerm*>::iterator it = postfix.begin(); it != postfix.end(); it++) { ExpressionTerm *term = *it; if (expressionVars.count(term) != 0) { opcode->addInterop(new ByteOperation(OP_PUSH)); opcode->addInterop(new DwordOperation(&expressionVars[term])); } else { addOperator(opcode, term->token); } } }
bool parserCls::term1(void) { bool s1 = term2(); if(s1==false) return false ; EtokenType et1=getTokenType();tokenContainCls t1 ; while( (et1== And )||(et1 == Or )|| (et1 == ExOr)) { t1 =getCurToken();getToken();bool s2 = term2(); if(s2==false) return false ; addOperator(t1);et1 = getTokenType(); } return s1 ; }
void GeneratorObjectImplementation::synchronizedUIListen(SceneObject* player, int value) { if (!player->isPlayerCreature() || !isOnAdminList(cast<CreatureObject*>(player)) || getZone() == NULL) return; addOperator(cast<CreatureObject*>(player)); updateInstallationWork(); HarvesterObjectMessage7* msg = new HarvesterObjectMessage7(_this.getReferenceUnsafeStaticCast()); player->sendMessage(msg); activateUiSync(); }
FreeWill::OperatorDescriptorHandle FreeWill::Model::addOperator(const std::string &name, const std::string &operatorNameString, const std::map<std::string, FreeWill::TensorDescriptorHandle> &inputs, const std::map<std::string, FreeWill::TensorDescriptorHandle> &outputs, const std::map<std::string, std::any> &properties, DataType dataType) { if (FreeWill::operatorNameTable.find(operatorNameString) != FreeWill::operatorNameTable.end()) { FreeWill::OperatorName operatorName = operatorNameTable[operatorNameString]; return addOperator(name, operatorName, inputs, outputs, properties, dataType); return name; } return std::string(); }
bool parserCls::factor(void) { EtokenType lTt1 = getTokenType(); bool bb1 = true ; tokenContainCls lTc1 =getCurToken(); switch(lTt1) { case OrdNumber: case SciNumber: case String : case Array : addOperand() ; exprFound = true ; needOperand = false ; noTokenInExpr++; getToken(); break ; case Name : exprFound = true ; needOperand = false ; noTokenInExpr++; getToken(); if(getTokenType() == Lparen ) addFunction(lTc1); else addName(lTc1) ; break ; case Lparen : addOperator() ; recursiveLparen() ; break ; case Rparen : break ; default : if(needOperand) errorFactor(); bb1 = false ; } return bb1 ; }
bool parserCls::contExpr(int ii1) { bool b2 = !exprErrorFlag ; if(b2) { if(tokenInExpr(ii1)) { b2 =true ; addOperator(); getToken() ; needOperand = true ; noTokenInExpr++; } else b2 = false ; } return b2 ; }
void HarvesterObjectImplementation::synchronizedUIListen(CreatureObject* player, int value) { if (!player->isPlayerCreature() || !isOnAdminList(player) || getZone() == NULL) return; addOperator(player); updateInstallationWork(); HarvesterObjectMessage7* msg = new HarvesterObjectMessage7(_this.getReferenceUnsafeStaticCast()); player->sendMessage(msg); /// Have to send the spawns of items no in shift, or the dont show /// up in the hopper when you look. for (int i = 0; i < resourceHopper.size(); ++i) { ResourceContainer* container = resourceHopper.get(i); if (container != NULL) { container->sendTo(player, true); } } activateUiSync(); }
OperatorFactory::OperatorFactory() { addOperator("+", spOp(new Add)); addOperator("-", spOp(new Subtract)); addOperator("!", spOp(new Factorial)); addOperator("*", spOp(new Multiply)); addOperator("/", spOp(new Divide)); addOperator("<", spOp(new LessThen)); addOperator(">", spOp(new GreaterThen)); addOperator("primeFactors", spOp(new PrimeFactors)); addOperator("sum", spOp(new Sum)); addOperator("drop", spOp(new Drop)); addOperator("dup", spOp(new Dup)); addOperator("ndup", spOp(new NDup)); addOperator("nop", spOp(new Nop)); addOperator("swap", spOp(new Swap)); addOperator("ifElse", spOp(new IfElse(getOperatorNamed("nop"), getOperatorNamed("nop")))); }
/** Append text to Expression. Overwrites a trailing operator with the new one, if a sequence of * two operators is input. * Recognizes and executes C, AC and = commands. */ void Calculator::addToExpressionText(const QString & buttonText) { QString text = buttonText; try{ if(text == "C") clearLast(); else if(text == "AC") clearAll(); else if(text == "+/-") changeSign(); else if(text == m_TextRad) setAngleMode(text); else if(text == m_TextDeg) setAngleMode(text); else if(text == "=") { if(isPlotExpression()) createPlot(); else parseExpression(); } else if(text=="x") addVariable(text); else if(text.startsWith("Plot")) plotter.processPlotCommand(text); else{ //we have a digit, operator or function //no clear or evaluate command if(text == "x^y") //convert to operator text = "^"; if(isNumber(text)){ //No parenthesis, we have a digit or a decimal separator addDigit(text); emit guiStateSuggested(STATE_STANDARD); //return to std page, if on Fn Page for entering E } else if(isOperator(text)) //operator or digit { addOperator(text); } else if(isParenthesis(text)) //we have a parenthesis { addParenthesis(text); } else if(isFunction(text)) //we have a function { addFunctionCall(text); } else if(isVariable(text)) //we have a variable { addVariable(text); } else throw ExExpressionError(tr("Unknown command:") + text); } //end digit operator or function m_ExpressionText = m_ExpressionParts.join(""); if(isPlotExpression()) emit expressionTextChanged("y=" + m_ExpressionText); else emit expressionTextChanged(m_ExpressionText); } //end try catch(ExExpressionError e) { emit guiStateSuggested(STATE_STANDARD); emit errorMessage(tr("Input Error"),e.what()); } catch(std::exception e) { emit guiStateSuggested(STATE_STANDARD); emit errorMessage(tr("Unknown Input Error"),e.what()); } }
void Smt2::addTheory(Theory theory) { switch(theory) { case THEORY_ARRAYS: Parser::addOperator(kind::SELECT); Parser::addOperator(kind::STORE); break; case THEORY_BITVECTORS: addBitvectorOperators(); break; case THEORY_CORE: defineType("Bool", getExprManager()->booleanType()); defineVar("true", getExprManager()->mkConst(true)); defineVar("false", getExprManager()->mkConst(false)); Parser::addOperator(kind::AND); Parser::addOperator(kind::DISTINCT); Parser::addOperator(kind::EQUAL); Parser::addOperator(kind::IFF); Parser::addOperator(kind::IMPLIES); Parser::addOperator(kind::ITE); Parser::addOperator(kind::NOT); Parser::addOperator(kind::OR); Parser::addOperator(kind::XOR); break; case THEORY_REALS_INTS: defineType("Real", getExprManager()->realType()); Parser::addOperator(kind::DIVISION); Parser::addOperator(kind::TO_INTEGER); Parser::addOperator(kind::IS_INTEGER); Parser::addOperator(kind::TO_REAL); // falling through on purpose, to add Ints part of Reals_Ints case THEORY_INTS: defineType("Int", getExprManager()->integerType()); addArithmeticOperators(); Parser::addOperator(kind::INTS_DIVISION); Parser::addOperator(kind::INTS_MODULUS); Parser::addOperator(kind::ABS); Parser::addOperator(kind::DIVISIBLE); break; case THEORY_REALS: defineType("Real", getExprManager()->realType()); addArithmeticOperators(); Parser::addOperator(kind::DIVISION); break; case THEORY_QUANTIFIERS: break; case THEORY_SETS: addOperator(kind::UNION, "union"); addOperator(kind::INTERSECTION, "intersection"); addOperator(kind::SETMINUS, "setminus"); addOperator(kind::SUBSET, "subset"); addOperator(kind::MEMBER, "member"); addOperator(kind::SINGLETON, "singleton"); addOperator(kind::INSERT, "insert"); break; case THEORY_DATATYPES: Parser::addOperator(kind::APPLY_CONSTRUCTOR); Parser::addOperator(kind::APPLY_TESTER); Parser::addOperator(kind::APPLY_SELECTOR); Parser::addOperator(kind::APPLY_SELECTOR_TOTAL); break; case THEORY_STRINGS: defineType("String", getExprManager()->stringType()); addStringOperators(); break; case THEORY_UF: Parser::addOperator(kind::APPLY_UF); break; default: std::stringstream ss; ss << "internal error: unsupported theory " << theory; throw ParserException(ss.str()); } }
void InfixToPostfix::loadLogicalOperators() { addOperator("!"); addOperator("or"); addOperator("and"); }