mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
fix the debug mode in the linearizer after the refactoring in libgu
This commit is contained in:
@@ -105,39 +105,39 @@ typedef struct {
|
|||||||
|
|
||||||
#ifdef PGF_LINEARIZER_DEBUG
|
#ifdef PGF_LINEARIZER_DEBUG
|
||||||
void
|
void
|
||||||
pgf_print_cnc_tree(PgfCncTree ctree, GuWriter* wtr, GuExn* err)
|
pgf_print_cnc_tree(PgfCncTree ctree, GuOut* out, GuExn* err)
|
||||||
{
|
{
|
||||||
GuVariantInfo ti = gu_variant_open(ctree);
|
GuVariantInfo ti = gu_variant_open(ctree);
|
||||||
switch (ti.tag) {
|
switch (ti.tag) {
|
||||||
case PGF_CNC_TREE_APP: {
|
case PGF_CNC_TREE_APP: {
|
||||||
PgfCncTreeApp* capp = ti.data;
|
PgfCncTreeApp* capp = ti.data;
|
||||||
if (capp->n_args > 0) gu_putc('(', wtr, err);
|
if (capp->n_args > 0) gu_putc('(', out, err);
|
||||||
gu_printf(wtr, err, "F%d", capp->fun->funid);
|
gu_printf(out, err, "F%d", capp->fun->funid);
|
||||||
for (size_t i = 0; i < capp->n_args; i++) {
|
for (size_t i = 0; i < capp->n_args; i++) {
|
||||||
gu_putc(' ', wtr, err);
|
gu_putc(' ', out, err);
|
||||||
pgf_print_cnc_tree(capp->args[i], wtr, err);
|
pgf_print_cnc_tree(capp->args[i], out, err);
|
||||||
}
|
}
|
||||||
if (capp->n_args > 0) gu_putc(')', wtr, err);
|
if (capp->n_args > 0) gu_putc(')', out, err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PGF_CNC_TREE_CHUNKS: {
|
case PGF_CNC_TREE_CHUNKS: {
|
||||||
PgfCncTreeChunks* chunks = ti.data;
|
PgfCncTreeChunks* chunks = ti.data;
|
||||||
if (chunks->n_args > 0) gu_putc('(', wtr, err);
|
if (chunks->n_args > 0) gu_putc('(', out, err);
|
||||||
gu_putc('?', wtr, err);
|
gu_putc('?', out, err);
|
||||||
for (size_t i = 0; i < chunks->n_args; i++) {
|
for (size_t i = 0; i < chunks->n_args; i++) {
|
||||||
gu_putc(' ', wtr, err);
|
gu_putc(' ', out, err);
|
||||||
pgf_print_cnc_tree(chunks->args[i], wtr, err);
|
pgf_print_cnc_tree(chunks->args[i], out, err);
|
||||||
}
|
}
|
||||||
if (chunks->n_args > 0) gu_putc(')', wtr, err);
|
if (chunks->n_args > 0) gu_putc(')', out, err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PGF_CNC_TREE_LIT: {
|
case PGF_CNC_TREE_LIT: {
|
||||||
PgfCncTreeLit* clit = ti.data;
|
PgfCncTreeLit* clit = ti.data;
|
||||||
pgf_print_literal(clit->lit, wtr, err);
|
pgf_print_literal(clit->lit, out, err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GU_VARIANT_NULL:
|
case GU_VARIANT_NULL:
|
||||||
gu_puts("null", wtr, err);
|
gu_puts("null", out, err);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
gu_impossible();
|
gu_impossible();
|
||||||
@@ -426,13 +426,12 @@ pgf_cnc_tree_enum_next(GuEnum* self, void* to, GuPool* pool)
|
|||||||
#ifdef PGF_LINEARIZER_DEBUG
|
#ifdef PGF_LINEARIZER_DEBUG
|
||||||
GuPool* tmp_pool = gu_new_pool();
|
GuPool* tmp_pool = gu_new_pool();
|
||||||
GuOut* out = gu_file_out(stderr, tmp_pool);
|
GuOut* out = gu_file_out(stderr, tmp_pool);
|
||||||
GuWriter* wtr = gu_new_utf8_writer(out, tmp_pool);
|
|
||||||
GuExn* err = gu_exn(NULL, type, tmp_pool);
|
GuExn* err = gu_exn(NULL, type, tmp_pool);
|
||||||
if (gu_variant_is_null(*toc))
|
if (gu_variant_is_null(*toc))
|
||||||
gu_puts("*nil*\n", wtr, err);
|
gu_puts("*nil*\n", out, err);
|
||||||
else {
|
else {
|
||||||
pgf_print_cnc_tree(*toc, wtr, err);
|
pgf_print_cnc_tree(*toc, out, err);
|
||||||
gu_puts("\n", wtr, err);
|
gu_puts("\n", out, err);
|
||||||
}
|
}
|
||||||
gu_pool_free(tmp_pool);
|
gu_pool_free(tmp_pool);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user