Ejemplo n.º 1
0
 static SEXP exception_to_r_condition( const std::exception& ex){
     std::string ex_class = Rcpp::demangle( typeid(ex).name() ) ;
     std::string ex_msg   = ex.what() ; 
     
     Scoped<SEXP> cppstack  = rcpp_get_stack_trace() ;
     Scoped<SEXP> call      = get_last_call() ;
     Scoped<SEXP> classes   = get_exception_classes(ex_class) ;
     Scoped<SEXP> condition = make_condition( ex_msg, call, cppstack, classes ) ; 
     rcpp_set_stack_trace( R_NilValue ) ;
     return condition ;
 }
Ejemplo n.º 2
0
SEXP exception_to_r_condition( const std::exception& ex){
    std::string ex_class = demangle( typeid(ex).name() ) ;
    std::string ex_msg   = ex.what() ; 
    
    SEXP cppstack = PROTECT( rcpp_get_stack_trace() ) ;
    SEXP call = PROTECT( get_last_call() ) ;
    SEXP classes = PROTECT( get_exception_classes(ex_class) ) ;
    SEXP condition = PROTECT( make_condition( ex_msg, call, cppstack, classes ) ) ; 
    rcpp_set_stack_trace( R_NilValue ) ;
    UNPROTECT(4) ;
    return condition ;
}
Ejemplo n.º 3
0
void sqlite_dialect_compiler::visit(const matador::detail::top &limit)
{
  // if statement was a limited updated statement
  // replace the where clause with a sub select
  if (!is_update && !is_delete) {
    return;
  }

  column rowid("rowid");
  auto where_token = std::static_pointer_cast<detail::where>(*where_);
  auto subselect = matador::select({rowid}).from(tablename_).where(where_token->cond).limit(limit.limit_);
  auto cond = make_condition(matador::in(rowid, subselect));

  where_token->cond.swap(cond);

  top().tokens_.erase(top().current);
}
Ejemplo n.º 4
0
int main (int argc, char **argv)
{
  CONDITION *head,*p;
  make_condition (argv[1],&head);
  
  p=head;
  for (p=head;p;p=p->next)
  {
    printf ("var=\'%s\'\n",p->var);
    printf ("var_id=\'%d\'\n",p->var_id);
    printf ("op=\'%s\'\n",p->op);
    printf ("op_id=\'%d\'\n",p->op_id);
    printf ("val=\'%s\'\n",p->val);   

  }
  free_conditions (head);
  return 0;
}
Ejemplo n.º 5
0
struct conditionNode* condition()
{
	struct conditionNode* cNode;
	struct varNode* var;
	//struct varNode* op2;
	struct statementNode* tBranch;
	struct statementNode* fBranch;
	int op;

	cNode = make_condition();

	ttype = getToken();
	//printf("ttype %d ln 1272\n", ttype);
	if ((ttype == ID)||(ttype == NUM))
	{
		//ungetToken(); //ungetToken since it still be parsed
		
		if(ttype == NUM)
		{
			var = make_var();
		
			if(symSearch(token) == NULL)
			{	
				symAdd(var);
			}
		
			cNode->op1 = symSearch(token);
		}
		else if (ttype == ID)
		{
			cNode->op1 = symSearch(token); //left operand of a condition is a primary
		}

		ttype = getToken();
		//printf("ttype %d ln 1273\n", ttype);
		if ((ttype == GREATER)||(ttype == GTEQ)||(ttype == LESS)
			||(ttype == NOTEQUAL)||(ttype == LTEQ))
		{
			cNode->operator = ttype; //relop is set to >, <, etc.
		
			ttype = getToken();
			//printf("ttype %d ln 1280\n", ttype);
			if ((ttype == ID)|(ttype == NUM))
			{
				//ungetToken(); //ungetToken since it still be parsed
				//cNode->op2 = symSearch(token); //right operand of a condition is a primary			
				
				if(ttype == NUM)
				{
					var = make_var();
		
					if(symSearch(token) == NULL)
					{	
						symAdd(var);
					}
		
					cNode->op2 = symSearch(token);
				}
				else if (ttype == ID)
				{
					cNode->op2 = symSearch(token); //left operand of a condition is a primary
				}
				
				return cNode;

			}
			else
			{
				return NULL;
			}
		}
		else
		{
			return NULL;
		}
	}
	else
	{
		return NULL;
	}
}
Ejemplo n.º 6
0
struct conditionNode* condition()
{
	struct conditionNode* cNode;
	struct varNode* op1;
	struct varNode* op2;
	struct statementNode* tBranch;
	struct statementNode* fBranch;
	int op;

	cNode = make_condition();

	ttype = getToken();
	if ((ttype == ID)|(ttype == NUM))
	{
		ungetToken(); //ungetToken since it still be parsed
		cNode->op1 = primary(); //left operand of a condition is a primary

		ttype = getToken();
		if ((ttype == GREATER)|(ttype == GTEQ)|(ttype == LESS)
			|(ttype == NOTEQUAL)|(ttype == LTEQ))
		{
			cNode->operator = ttype; //relop is set to >, <, etc.
		
			ttype = getToken();
			if ((ttype == ID)|(ttype == NUM))
			{
				ungetToken(); //ungetToken since it still be parsed
				cNode->op2 = primary(); //right operand of a condition is a primary
			
				ttype = getToken();
				if(ttype == RPAREN)
				{
					ttype = getToken();
					if(ttype == THEN)
					{
						cNode->trueBranch = stmt_list();
						return cNode;
					}
					else
					{
						return NULL;
					}
				}
				else
				{
					return NULL;
				}
			}
			else
			{
				return NULL;
			}
		}
		else
		{
			return NULL;
		}
	}
	else
	{
		return NULL;
	}
}