forked from GitHub/gf-core
bugfix in the robust linearizer
This commit is contained in:
@@ -281,10 +281,7 @@ pgf_lzn_resolve_def(PgfLzn* lzn, PgfCncFuns* lindefs, GuString s, GuPool* pool)
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GuMapItor fn;
|
GuMapItor fn;
|
||||||
PgfLzn* lzn;
|
GuBuf* buf;
|
||||||
GuBuf* args;
|
|
||||||
GuPool* pool;
|
|
||||||
PgfCncTree ctree;
|
|
||||||
} PgfLznItor;
|
} PgfLznItor;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -293,8 +290,11 @@ pgf_lzn_cat_resolve_itor(GuMapItor* fn, const void* key, void* value, GuExn* err
|
|||||||
PgfLznItor* clo = (PgfLznItor*) fn;
|
PgfLznItor* clo = (PgfLznItor*) fn;
|
||||||
GuBuf* buf = *((GuBuf**) value);
|
GuBuf* buf = *((GuBuf**) value);
|
||||||
|
|
||||||
if (gu_variant_is_null(clo->ctree))
|
for (size_t i = 0; i < gu_buf_length(buf); i++) {
|
||||||
clo->ctree = pgf_lzn_resolve_app(clo->lzn, buf, clo->args, clo->pool);
|
PgfProductionApply* apply =
|
||||||
|
gu_buf_get(buf, PgfProductionApply*, i);
|
||||||
|
gu_buf_push(clo->buf, PgfProductionApply*, apply);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PgfCncTree
|
static PgfCncTree
|
||||||
@@ -327,11 +327,6 @@ pgf_lzn_resolve(PgfLzn* lzn, PgfExpr expr, PgfCCat* ccat, GuPool* pool)
|
|||||||
if (ccat == NULL) {
|
if (ccat == NULL) {
|
||||||
size_t n_args = gu_buf_length(args);
|
size_t n_args = gu_buf_length(args);
|
||||||
|
|
||||||
int flag = gu_choice_next(lzn->ch, 1);
|
|
||||||
if (flag == 0) {
|
|
||||||
return gu_null_variant;
|
|
||||||
}
|
|
||||||
|
|
||||||
PgfCncTreeChunks* chunks =
|
PgfCncTreeChunks* chunks =
|
||||||
gu_new_flex_variant(PGF_CNC_TREE_CHUNKS,
|
gu_new_flex_variant(PGF_CNC_TREE_CHUNKS,
|
||||||
PgfCncTreeChunks,
|
PgfCncTreeChunks,
|
||||||
@@ -398,9 +393,13 @@ pgf_lzn_resolve(PgfLzn* lzn, PgfExpr expr, PgfCCat* ccat, GuPool* pool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ccat == NULL) {
|
if (ccat == NULL) {
|
||||||
PgfLznItor clo = { { pgf_lzn_cat_resolve_itor }, lzn, args, pool, gu_null_variant };
|
GuPool* tmp_pool = gu_local_pool();
|
||||||
|
GuBuf* buf =
|
||||||
|
gu_new_buf(PgfProductionApply*, tmp_pool);
|
||||||
|
PgfLznItor clo = { { pgf_lzn_cat_resolve_itor }, buf };
|
||||||
gu_map_iter(overl_table, &clo.fn, NULL);
|
gu_map_iter(overl_table, &clo.fn, NULL);
|
||||||
ret = clo.ctree;
|
ret = pgf_lzn_resolve_app(lzn, buf, args, pool);
|
||||||
|
gu_pool_free(tmp_pool);
|
||||||
} else {
|
} else {
|
||||||
GuBuf* buf =
|
GuBuf* buf =
|
||||||
gu_map_get(overl_table, ccat, GuBuf*);
|
gu_map_get(overl_table, ccat, GuBuf*);
|
||||||
|
|||||||
Reference in New Issue
Block a user