Exemplo n.º 1
0
int main()
{
	enum token_id  t_id = T_NIL;
	enum symbol_id s_id = S_NIL;

	for (s_id = S_NIL; s_id <= 550; s_id++) {
		printf("s_id=%d: %s\n", s_id, trans_symbol(s_id));
	}

	printf("\n");

	for (t_id = T_NIL; t_id < T_N + 2; t_id++) {
		printf("t_id=%d: %s\n", t_id, trans_token(t_id));
	}
}
Exemplo n.º 2
0
Arquivo: tex-tr.c Projeto: t-k-/OPMES
static TREE_IT_CALLBK(print)
{
	TREE_OBJ(struct tex_tr, p, tnd);
	P_CAST(fh, FILE, pa_extra);
	int i;
	BOOL is_leaf;
	
	if (p->tnd.sons.now == NULL /* is leaf */)
		is_leaf = 1;
	else
		is_leaf = 0;

	if (pa_now->now == pa_head->last)
		depth_flag[pa_depth] = depth_going_end;
	else if (pa_now->now == pa_head->now)
		depth_flag[pa_depth] = depth_begin;
	
	for (i = 0; i<pa_depth; i++) { 
		switch (depth_flag[i + 1]) {
		case depth_end:
			fprintf(fh, "    ");
			break;
		case depth_begin:
			fprintf(fh, "   │");
			break;
		case depth_going_end:
			fprintf(fh, "   └");
			break;
		default:
			break;
		}
	}
	
	if (is_leaf) 
		fprintf(fh, "──[");
	else 
		fprintf(fh, "──(");

#if (DEBUG_TEX_TR_PRINT_ID)
	fprintf(fh, "s%d, t%d, #%d, *%d, @%d", p->symbol_id, 
	        p->token_id, p->node_id, p->n_fan, p->rank);
#else
	fprintf(fh, "%s, %s, #%d, *%d, @%d", 
	        trans_symbol(p->symbol_id), 
	        trans_token(p->token_id), 
	        p->node_id, p->n_fan, p->rank);
#endif

	if (is_leaf) 
		fprintf(fh, "]");
	else 
		fprintf(fh, ")");
	
	if (p->n_fan == 0 && is_leaf)
		fprintf(fh, " (grouped)");
	
	fprintf(fh, "\n");

	if (depth_flag[pa_depth] == depth_going_end)
		depth_flag[pa_depth] = depth_end;
	LIST_GO_OVER;
}