link-grammar-5.8.0/link-grammar/dict-sql/read-sql.c
/* callback -- set bs->exp to the expressions for a class in the dict */
- set bs->exp to the expressions for a class in the dict
- set bs - > exp to the expressions for a class in the dict
static int exp_cb(void *user_data, int argc, char **argv, char **colName)
{
	cbdata* bs = user_data;
	Dictionary dict = bs->dict;
	assert(2 == argc, "Bad column count");
	assert(argv[0], "NULL column value");
	Exp* exp = NULL;
	make_expression(dict, argv[0], &exp);
	assert(NULL != exp, "Failed expression %s", argv[0]);
	if (!strtodC(argv[1], &exp->cost))
	{
		prt_error("Warning: Invalid cost \"%s\" in expression \"%s\" "
		          "(using 1.0)\n", argv[1], argv[0]);
		exp->cost = 1.0;
	}
	if (NULL == bs->exp)
	{
		bs->exp = exp;
		return 0;
	}
	if (OR_type != bs->exp->type)
	{
		Exp* orn = Exp_create(dict->Exp_pool);
		orn->type = OR_type;
		orn->cost = 0.0;
		orn->operand_first = exp;
		exp->operand_next = bs->exp;
		bs->exp = orn;
		return 0;
	}
	exp->operand_next = bs->exp->operand_first;
	bs->exp->operand_first = exp;
	return 0;
}
static int exp_cb ( void * user_data , int argc , char * * argv , char * * colName ) { cbdata * bs = user_data ; Dictionary dict = bs -> dict ; assert ( 2 == argc , " " ) ; assert ( argv [ 0 ] , " " ) ; Exp * exp = NULL ; make_expression ( dict , argv [ 0 ] , & exp ) ; assert ( NULL != exp , " " , argv [ 0 ] ) ; if ( ! strtodC ( argv [ 1 ] , & exp -> cost ) ) { prt_error ( " \" \" \" \" " " \n " , argv [ 1 ] , argv [ 0 ] ) ; exp -> cost = 1.0 ; } if ( NULL == bs -> exp ) { bs -> exp = exp ; return 0 ; } if ( OR_type != bs -> exp -> type ) { Exp * orn = Exp_create ( dict -> Exp_pool ) ; orn -> type = OR_type ; orn -> cost = 0.0 ; orn -> operand_first = exp ; exp -> operand_next = bs -> exp ; bs -> exp = orn ; return 0 ; } exp -> operand_next = bs -> exp -> operand_first ; bs -> exp -> operand_first = exp ; return 0 ; }
callback -- set bs->exp to the expressions for a class in the dict
callback -- set bs - > exp to the expressions for a class in the dict
/* If the very first expression, just put it in place */ /* If the second expression, OR-it with the existing expression. */ /* Extend the OR-chain for the third and later expressions. */