mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
bugfix for linearization of metavariables at the root of a tree
This commit is contained in:
@@ -210,8 +210,22 @@ redo:;
|
|||||||
static PgfCncTree
|
static PgfCncTree
|
||||||
pgf_lzn_resolve_def(PgfLzn* lzn, PgfFunIds* lindefs, GuString s, GuPool* pool)
|
pgf_lzn_resolve_def(PgfLzn* lzn, PgfFunIds* lindefs, GuString s, GuPool* pool)
|
||||||
{
|
{
|
||||||
|
PgfCncTree lit = gu_null_variant;
|
||||||
PgfCncTree ret = gu_null_variant;
|
PgfCncTree ret = gu_null_variant;
|
||||||
|
|
||||||
|
PgfCncTreeLit* clit =
|
||||||
|
gu_new_variant(PGF_CNC_TREE_LIT,
|
||||||
|
PgfCncTreeLit,
|
||||||
|
&lit, pool);
|
||||||
|
clit->lit =
|
||||||
|
gu_new_variant_i(pool,
|
||||||
|
PGF_LITERAL_STR,
|
||||||
|
PgfLiteralStr,
|
||||||
|
s);
|
||||||
|
|
||||||
|
if (lindefs == NULL)
|
||||||
|
return lit;
|
||||||
|
|
||||||
int index =
|
int index =
|
||||||
gu_choice_next(lzn->ch, gu_list_length(lindefs));
|
gu_choice_next(lzn->ch, gu_list_length(lindefs));
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
@@ -223,16 +237,7 @@ pgf_lzn_resolve_def(PgfLzn* lzn, PgfFunIds* lindefs, GuString s, GuPool* pool)
|
|||||||
args, 1, &ret, pool);
|
args, 1, &ret, pool);
|
||||||
capp->fun = gu_list_index(lindefs, index);
|
capp->fun = gu_list_index(lindefs, index);
|
||||||
capp->n_args = 1;
|
capp->n_args = 1;
|
||||||
|
capp->args[0] = lit;
|
||||||
PgfCncTreeLit* clit =
|
|
||||||
gu_new_variant(PGF_CNC_TREE_LIT,
|
|
||||||
PgfCncTreeLit,
|
|
||||||
&capp->args[0], pool);
|
|
||||||
clit->lit =
|
|
||||||
gu_new_variant_i(pool,
|
|
||||||
PGF_LITERAL_STR,
|
|
||||||
PgfLiteralStr,
|
|
||||||
s);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -281,12 +286,13 @@ pgf_lzn_resolve(PgfLzn* lzn, PgfExpr expr, PgfCCat* ccat, GuPool* pool)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
case PGF_EXPR_META: {
|
case PGF_EXPR_META: {
|
||||||
if (ccat->lindefs == NULL)
|
PgfFunIds* lindefs = NULL;
|
||||||
|
if (ccat != NULL && ccat->lindefs == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
GuString s = gu_str_string("?", pool);
|
GuString s = gu_str_string("?", pool);
|
||||||
|
ret = pgf_lzn_resolve_def(lzn, lindefs, s, pool);
|
||||||
ret = pgf_lzn_resolve_def(lzn, ccat->lindefs, s, pool);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
case PGF_EXPR_FUN: {
|
case PGF_EXPR_FUN: {
|
||||||
@@ -295,8 +301,10 @@ pgf_lzn_resolve(PgfLzn* lzn, PgfExpr expr, PgfCCat* ccat, GuPool* pool)
|
|||||||
PgfCncOverloadMap* overl_table =
|
PgfCncOverloadMap* overl_table =
|
||||||
gu_map_get(lzn->concr->fun_indices, &efun->fun, PgfCncOverloadMap*);
|
gu_map_get(lzn->concr->fun_indices, &efun->fun, PgfCncOverloadMap*);
|
||||||
if (overl_table == NULL) {
|
if (overl_table == NULL) {
|
||||||
if (ccat->lindefs == NULL)
|
PgfFunIds* lindefs = NULL;
|
||||||
|
if (ccat != NULL && ccat->lindefs == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
GuPool* tmp_pool = gu_local_pool();
|
GuPool* tmp_pool = gu_local_pool();
|
||||||
GuExn* err = gu_new_exn(NULL, gu_kind(type), tmp_pool);
|
GuExn* err = gu_new_exn(NULL, gu_kind(type), tmp_pool);
|
||||||
@@ -308,8 +316,7 @@ pgf_lzn_resolve(PgfLzn* lzn, PgfExpr expr, PgfCCat* ccat, GuPool* pool)
|
|||||||
gu_putc(']', wtr, err);
|
gu_putc(']', wtr, err);
|
||||||
GuString s = gu_string_buf_freeze(sbuf, tmp_pool);
|
GuString s = gu_string_buf_freeze(sbuf, tmp_pool);
|
||||||
|
|
||||||
ret = pgf_lzn_resolve_def(lzn, ccat->lindefs, s,
|
ret = pgf_lzn_resolve_def(lzn, lindefs, s, pool);
|
||||||
pool);
|
|
||||||
|
|
||||||
gu_pool_free(tmp_pool);
|
gu_pool_free(tmp_pool);
|
||||||
goto done;
|
goto done;
|
||||||
|
|||||||
@@ -1945,7 +1945,7 @@ pgf_parser_init_state(PgfConcr* concr, PgfCId cat, size_t lin_idx, GuPool* pool)
|
|||||||
conts->outside_prob = 0;
|
conts->outside_prob = 0;
|
||||||
conts->ref_count = 0;
|
conts->ref_count = 0;
|
||||||
gu_buf_push(conts->items, PgfItem*, NULL);
|
gu_buf_push(conts->items, PgfItem*, NULL);
|
||||||
|
|
||||||
#ifdef PGF_COUNTS_DEBUG
|
#ifdef PGF_COUNTS_DEBUG
|
||||||
ps->cont_full_count++;
|
ps->cont_full_count++;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user