link-grammar-5.8.0/link-grammar/dict-common/print-dict.c
/**
 * Print nested macros for each desired connector.
 * The desired connector positions are in find_pos[] (ascending sorted,
 * -1 terminated). Its first element holds the next position of the next
 *  connector to print, and is chopped after the connector is printed.
 */
Print nested macros for each desired connector.
The desired connector positions are in find_pos[] (ascending sorted,
-1 terminated). Its first element holds the next position of the next
connector to print, and is chopped after the connector is printed.
Print nested macros for each desired connector . The desired connector positions are in find_pos [] ( ascending sorted - 1 terminated ) . Its first element holds the next position of the next connector to print and is chopped after the connector is printed .
static void print_connector_macros(cmacro_context *cmc, const Exp *n)
{
	if ((cmc->find_pos)[0] == -1)
		return; 
	bool macro_started = false;
	int current_pos = cmc->pos;
	if ((Exptag_macro == n->tag_type) &&
	    exp_contains_connector(n, &current_pos, (cmc->find_pos)[0]))
	{
		if (cmc->is_after_connector)
		{
			dyn_strcat(cmc->e, " & ");
			cmc->is_after_connector = false;
		}
		print_expression_tag_start(cmc->dict, cmc->e, n, &cmc->indent);
		macro_started = true;
	}
	Exp *opd = n->operand_first;
	if (n->type == CONNECTOR_type)
	{
		if ((cmc->find_pos)[0] == cmc->pos)
		{
			if (cmc->is_after_connector) dyn_strcat(cmc->e, " & ");
			cmc->is_after_connector = true;
			if (n->multi) dyn_strcat(cmc->e, "@");
			dyn_strcat(cmc->e,
			           n->condesc ? n->condesc->string : "error-null-connector");
			dyn_strcat(cmc->e, (const char []){ n->dir, '\0' });
			cmc->find_pos++; 
		}
		cmc->pos++;
	}
	else
	{
		for (Exp *l = opd; l != NULL; l = l->operand_next)
		{
			print_connector_macros(cmc, l);
		}
	}
	if (macro_started && ((cmc->find_pos)[0] != -1))
		print_expression_tag_end(cmc->dict, cmc->e, n, &cmc->indent);
}
static void print_connector_macros ( cmacro_context * cmc , const Exp * n ) { if ( ( cmc -> find_pos ) [ 0 ] == -1 ) return ; bool macro_started = false ; int current_pos = cmc -> pos ; if ( ( Exptag_macro == n -> tag_type ) && exp_contains_connector ( n , & current_pos , ( cmc -> find_pos ) [ 0 ] ) ) { if ( cmc -> is_after_connector ) { dyn_strcat ( cmc -> e , " " ) ; cmc -> is_after_connector = false ; } print_expression_tag_start ( cmc -> dict , cmc -> e , n , & cmc -> indent ) ; macro_started = true ; } Exp * opd = n -> operand_first ; if ( n -> type == CONNECTOR_type ) { if ( ( cmc -> find_pos ) [ 0 ] == cmc -> pos ) { if ( cmc -> is_after_connector ) dyn_strcat ( cmc -> e , " " ) ; cmc -> is_after_connector = true ; if ( n -> multi ) dyn_strcat ( cmc -> e , " " ) ; dyn_strcat ( cmc -> e , n -> condesc ? n -> condesc -> string : " " ) ; dyn_strcat ( cmc -> e , ( const char [ ] ) { n -> dir , ' \0 ' } ) ; cmc -> find_pos ++ ; } cmc -> pos ++ ; } else { for ( Exp * l = opd ; l != NULL ; l = l -> operand_next ) { print_connector_macros ( cmc , l ) ; } } if ( macro_started && ( ( cmc -> find_pos ) [ 0 ] != -1 ) ) print_expression_tag_end ( cmc -> dict , cmc -> e , n , & cmc -> indent ) ; }
Print nested macros for each desired connector.
Print nested macros for each desired connector .
/* fast termination when nothing more to do */ /* each expression position is used only once */ /* The -1 check is to suppress unneeded newlines at the end. */