Ejemplo n.º 1
0
/** fixes variables to zero if the corresponding packings are not valid for this sonstraint/node (due to branching) */
static
SCIP_RETCODE consdataFixVariables(
   SCIP*                 scip,               /**< SCIP data structure */
   SCIP_CONSDATA*        consdata,           /**< constraint data */
   SCIP_VAR**            vars,               /**< generated variables */
   int                   nvars,              /**< number of generated variables */
   SCIP_RESULT*          result              /**< pointer to store the result of the fixing */
   )
{
   int nfixedvars;
   int v;
   SCIP_Bool cutoff;

   nfixedvars = 0;
   cutoff = FALSE;

   SCIPdebugMessage("check variables %d to %d\n", consdata->npropagatedvars, nvars);

   for( v = consdata->npropagatedvars; v < nvars && !cutoff; ++v )
   {
      SCIP_CALL( checkVariable(scip, consdata, vars[v], &nfixedvars, &cutoff) );
   }

   SCIPdebugMessage("fixed %d variables locally\n", nfixedvars);

   if( cutoff )
      *result = SCIP_CUTOFF;
   else if( nfixedvars > 0 )
      *result = SCIP_REDUCEDDOM;

   return SCIP_OKAY;
}
Ejemplo n.º 2
0
int main(void) {
char s[1000];
countVar=0;
countAlias=0;
getcwd(currentPath,100);

system("clear");
while(1)
{
	printf("> ");
	init();
	readCmd();
	checkVariable();
	if(strcmp("unalias",tokens[cmds[0].args[0]])!=0)
		checkAlias();
	
	checkWildcard();

	replaceHomePath();
 
	if(buildInCmd())
        continue;
    exeNormalCmd();

}
return 0;
}
std::shared_ptr<inter::LogicalExpression> SemanticChecker::checkLogicalExpression(inter::ScopePrototype & scopePrototype, syntax::LogicalExpression & condition)
{
    CHECK_FAIL(nullptr);

    std::shared_ptr<inter::LogicalExpression> obj = std::make_shared<inter::LogicalExpression>();

    obj->operation = condition._operation;
    obj->negated = condition._isNegated;

    for (auto & operand : condition._operands)
    {
        if (operand->getType() == syntax::Node::Type::LogicalExpression)
        {
            obj->operands.push_back(checkLogicalExpression(scopePrototype, *(static_cast<syntax::LogicalExpression*>(operand.get()))));
        }
        else if (operand->getType() == syntax::Node::Type::Variable)
        {
            obj->operands.push_back(checkVariable(scopePrototype, *(static_cast<syntax::Variable*>(operand.get()))));
        }
        else if (operand->getType() == syntax::Node::Type::Call)
        {
            obj->operands.push_back(checkFunctionCall(scopePrototype, *(static_cast<syntax::Call*>(operand.get()))));
        }
        else if (operand->getType() == syntax::Node::Type::ArithmeticExpression)
        {
            obj->operands.push_back(checkArithmeticExpression(scopePrototype, *(static_cast<syntax::ArithmeticExpression*>(operand.get()))));
        }
        else
        {
            typedef syntax::Node::Type Type;
            Type nodeType = operand->getType();
            if (nodeType == Type::Number)
                obj->operands.push_back(this->checkLiteral(scopePrototype, *(static_cast<syntax::Literal*>(operand.get())), "float"));
            else if (nodeType == Type::Bool)
                obj->operands.push_back(this->checkLiteral(scopePrototype, *(static_cast<syntax::Literal*>(operand.get())), "bool"));
            else
            {
                MessageHandler::error(std::string("Invalid logical expression operand!"));
                FAIL;
                return nullptr;
            }
        }
    }

    return obj;
}
Ejemplo n.º 4
0
TypePtr VariableTable::addParamLike(const string &name, TypePtr type,
                                    AnalysisResultPtr ar,
                                    ConstructPtr construct, bool firstPass) {
  TypePtr ret = type;
  if (firstPass) {
    ret = add(name, ret, false, ar,
              construct, ModifierExpressionPtr());
  } else {
    ret = checkVariable(name, ret, true, ar, construct);
    if (ret->is(Type::KindOfSome)) {
      // This is probably too conservative. The problem is that
      // a function never called will have parameter types of Any.
      // Functions that it calls won't be able to accept variant unless
      // it is forced here.
      forceVariant(ar, name, VariableTable::AnyVars);
      ret = Type::Variant;
    }
  }
  return ret;
}
Ejemplo n.º 5
0
bool InputOutputMaster::convertToPrintable (int cStart, int cEnd, Printable ** ppOutput ) {
    cRead=cStart;
    //for (cRead=cStart;cRead<MAXSIZE;cRead++){
    if (findLastOperator (cStart,cEnd,ppOutput)) return true;
    Expression ** peProduct=new Expression *;
    Expression ** peMultiplyBy=new Expression *;
    bool bFirst=true;
    for (; cRead<cEnd; cRead++) {
        int cAscii=(int) hTest [cRead];
        if (! (cAscii==41) ) {//ignore close brackets
            if (cAscii==40) {
                int cCloseBracket=findClosingBracket(cRead,cEnd);//(
                Printable ** ppBracket=new Printable *;
                if(  ! (convertToPrintable (cRead+1,cCloseBracket,ppBracket) )) return false;//if (hTest[cRead]== '(') deal with brackets
                *peMultiplyBy=static_cast<Expression*> (*ppBracket);
                cRead=cCloseBracket;
            }
            else if (cAscii==91) checkNamedConstant (peMultiplyBy,cEnd);//[
            else if (cAscii>47&&cAscii<58) checkConstant (peMultiplyBy);//0-9
            else if(checkFunction (peMultiplyBy,cEnd)) ;
            else if(cAscii==45) {
                checkMinus (peMultiplyBy,cEnd);   //-
            }
            else if (cAscii==105) {
                checkImaginary (peMultiplyBy);   //i
            }
            else checkVariable(cAscii, peMultiplyBy);
            checkForPostFunctions(peMultiplyBy);
            if (bFirst) {
                *peProduct = *peMultiplyBy;
                bFirst = false;
            } else {
                *peProduct = createOperator(MULTIPLY, *peProduct, *peMultiplyBy);
            }
        }
    }
    *ppOutput = static_cast<Printable*> (*peProduct);
    //delete peProduct;delete peMultiplyBy; //? I get an error with this in, but should it not be there?
    return true;
}
Ejemplo n.º 6
0
TypePtr VariableTable::checkVariable(const string &name, TypePtr type,
                                     bool coerce, AnalysisResultConstPtr ar,
                                     ConstructPtr construct) {
  return checkVariable(addSymbol(name), type,
                       coerce, ar, construct);
}
Ejemplo n.º 7
0
int scanFile(FILE *fp){
    if(fp == NULL){
        printf("File could not be found.\n");
        return -1;
    }

    printf("Reading in tokens...");

    while(fpeek(fp) != EOF){
        int tokenStart = fgetc(fp);
        int error = 0;

        //If we read whitespace, continue;
        if(tokenStart == '\n' || tokenStart == '\r' || tokenStart == '\t' ||
           tokenStart == '\v' || tokenStart == ' '){
               continue;
        }

        error = checkSymbols(fp, tokenStart);

        if(error == 4){
           printf("ERROR Invalid symbol '%c'\n", tokenStart);
           exit(4);
        }
        else if(error == 0){
           continue;
        }

        error = checkReservedWords(fp, tokenStart);

        if(error == -1){

           error = checkVariable(fp, tokenStart);

           if(error == 3){
               printf("ERROR Name exceeds 11 characters\n");
               exit(3);
           }
           else if(error == 0){
               continue;
           }
        }
        else if(error == 0){
           continue;
        }

        error = checkNumber(fp, tokenStart);

        if(error == 2){
           printf("ERROR number exceeds 5 digits\n");
           exit(2);
        }
        else if(error == 1){
           printf("ERROR Variables can't start with a letter");
           exit(1);
        }
        else if(error == 0){
           continue;
        }
    }

    createToken("null", 1);
    printf("COMPLETE\n");
    return 0;


}