link-grammar-5.8.0/link-grammar/dict-file/read-dict.c
/**
 * make_connector() -- make a node for a connector or dictionary word.
 *
 * Assumes the current token is a connector or dictionary word.
 */
- make a node for a connector or dictionary word.
Assumes the current token is a connector or dictionary word.
- make a node for a connector or dictionary word . Assumes the current token is a connector or dictionary word .
static Exp * make_connector(Dictionary dict)
{
	Exp * n;
	Dict_node *dn, *dn_head;
	int i;
	i = strlen(dict->token) - 1;  
	if ((dict->token[i] != '+') &&
	    (dict->token[i] != '-') &&
	    (dict->token[i] != ANY_DIR))
	{
		patch_subscript(dict->token);
		dn_head = abridged_lookup_list(dict, dict->token);
		dn = dn_head;
		while ((dn != NULL) && (strcmp(dn->string, dict->token) != 0))
		{
			dn = dn->right;
		}
		if (dn == NULL)
		{
			file_free_lookup(dn_head);
			dict_error(dict, "Perhaps missing + or - in a connector.\n"
			                 "Or perhaps you forgot the subscript on a word.\n"
			                 "Or perhaps a word is used before it is defined.");
			return NULL;
		}
		n = make_unary_node(dict->Exp_pool, dn->exp);
		n->tag_id = exptag_macro_add(dict, dn->string);
		if (n->tag_id != 0) n->tag_type = Exptag_macro;
		file_free_lookup(dn_head);
	}
	else
	{
		if (!check_connector(dict, dict->token))
		{
			return NULL;
		}
		if ((dict->token[i] == '+') || (dict->token[i] == '-'))
		{
			n = make_dir_connector(dict, i);
			if (NULL == n) return NULL;
		}
		else if (dict->token[i] == ANY_DIR)
		{
			Exp *plu, *min;
			dict->token[i] = '+';
			plu = make_dir_connector(dict, i);
			if (NULL == plu) return NULL;
			dict->token[i] = '-';
			min = make_dir_connector(dict, i);
			if (NULL == min) return NULL;
			n = make_or_node(dict->Exp_pool, plu, min);
		}
		else
		{
			dict_error(dict, "Unknown connector direction type.");
			return NULL;
		}
	}
	if (!link_advance(dict))
	{
		free(n);
		return NULL;
	}
	return n;
}
static Exp * make_connector ( Dictionary dict ) { Exp * n ; Dict_node * dn , * dn_head ; int i ; i = strlen ( dict -> token ) - 1 ; if ( ( dict -> token [ i ] != ' ' ) && ( dict -> token [ i ] != ' ' ) && ( dict -> token [ i ] != ANY_DIR ) ) { patch_subscript ( dict -> token ) ; dn_head = abridged_lookup_list ( dict , dict -> token ) ; dn = dn_head ; while ( ( dn != NULL ) && ( strcmp ( dn -> string , dict -> token ) != 0 ) ) { dn = dn -> right ; } if ( dn == NULL ) { file_free_lookup ( dn_head ) ; dict_error ( dict , " \n " " \n " " " ) ; return NULL ; } n = make_unary_node ( dict -> Exp_pool , dn -> exp ) ; n -> tag_id = exptag_macro_add ( dict , dn -> string ) ; if ( n -> tag_id != 0 ) n -> tag_type = Exptag_macro ; file_free_lookup ( dn_head ) ; } else { if ( ! check_connector ( dict , dict -> token ) ) { return NULL ; } if ( ( dict -> token [ i ] == ' ' ) || ( dict -> token [ i ] == ' ' ) ) { n = make_dir_connector ( dict , i ) ; if ( NULL == n ) return NULL ; } else if ( dict -> token [ i ] == ANY_DIR ) { Exp * plu , * min ; dict -> token [ i ] = ' ' ; plu = make_dir_connector ( dict , i ) ; if ( NULL == plu ) return NULL ; dict -> token [ i ] = ' ' ; min = make_dir_connector ( dict , i ) ; if ( NULL == min ) return NULL ; n = make_or_node ( dict -> Exp_pool , plu , min ) ; } else { dict_error ( dict , " " ) ; return NULL ; } } if ( ! link_advance ( dict ) ) { free ( n ) ; return NULL ; } return n ; }
make_connector() -- make a node for a connector or dictionary word.
make_connector () -- make a node for a connector or dictionary word .
/* this must be +, - or $ if a connector */ /* If we are here, token is a word */ /* Wrap it in a unary node as a placeholder for a macro tag and cost. */ /* If we are here, token is a connector */ /* A simple, unidirectional connector. Just make that. */ /* If we are here, then it's a bi-directional connector.
			 * Make both a + and a - version, and or them together.  */