mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
libpgf: now the debugging mode for the parser is available only with compilation option.
This commit is contained in:
@@ -87,16 +87,7 @@ struct PgfParsing {
|
|||||||
int max_fid;
|
int max_fid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef PGF_PARSER_DEBUG
|
||||||
static bool
|
|
||||||
pgf_parser_debug() {
|
|
||||||
const char* cfg = getenv("PGF_PARSER_DEBUG");
|
|
||||||
if (cfg == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return strcmp(cfg, "yes") == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pgf_print_production(int fid, PgfProduction prod, GuWriter *wtr, GuExn* err)
|
pgf_print_production(int fid, PgfProduction prod, GuWriter *wtr, GuExn* err)
|
||||||
{
|
{
|
||||||
@@ -409,20 +400,18 @@ pgf_parsing_complete(PgfParsing* parsing, PgfItem* item)
|
|||||||
GuBuf* prodbuf = gu_seq_buf(cat->prods);
|
GuBuf* prodbuf = gu_seq_buf(cat->prods);
|
||||||
gu_buf_push(prodbuf, PgfProduction, prod);
|
gu_buf_push(prodbuf, PgfProduction, prod);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef PGF_PARSER_DEBUG
|
||||||
if (pgf_parser_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);
|
||||||
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 (tmp_cat == NULL)
|
||||||
if (tmp_cat == NULL)
|
gu_printf(wtr, err, "[C%d; %d; C%d]\n",
|
||||||
gu_printf(wtr, err, "[C%d; %d; C%d]\n",
|
|
||||||
item->base->ccat->fid,
|
item->base->ccat->fid,
|
||||||
item->base->lin_idx,
|
item->base->lin_idx,
|
||||||
cat->fid);
|
cat->fid);
|
||||||
pgf_print_production(cat->fid, prod, wtr, err);
|
pgf_print_production(cat->fid, prod, wtr, err);
|
||||||
gu_pool_free(tmp_pool);
|
gu_pool_free(tmp_pool);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tmp_cat != NULL) {
|
if (tmp_cat != NULL) {
|
||||||
@@ -583,15 +572,13 @@ pgf_parsing_symbol(PgfParsing* parsing, PgfItem* item, PgfSymbol sym) {
|
|||||||
static void
|
static void
|
||||||
pgf_parsing_item(PgfParsing* parsing, PgfItem* item)
|
pgf_parsing_item(PgfParsing* parsing, PgfItem* item)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifdef PGF_PARSER_DEBUG
|
||||||
if (pgf_parser_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);
|
||||||
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);
|
pgf_print_item(item, wtr, err);
|
||||||
pgf_print_item(item, wtr, err);
|
gu_pool_free(tmp_pool);
|
||||||
gu_pool_free(tmp_pool);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GuVariantInfo i = gu_variant_open(item->base->prod);
|
GuVariantInfo i = gu_variant_open(item->base->prod);
|
||||||
|
|||||||
Reference in New Issue
Block a user