forked from GitHub/gf-core
libpgf: extra_ccat is now redundant and was removed
This commit is contained in:
@@ -206,20 +206,6 @@ pgf_lzr_index(PgfLzr* lzr, PgfCCat* cat, PgfProduction prod)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
pgf_lzr_index_ccat(PgfLzr* lzr, PgfCCat* cat)
|
|
||||||
{
|
|
||||||
gu_debug("ccat: %d", cat->fid);
|
|
||||||
if (gu_seq_is_null(cat->prods)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
size_t n_prods = gu_seq_length(cat->prods);
|
|
||||||
for (size_t i = 0; i < n_prods; i++) {
|
|
||||||
PgfProduction prod = gu_seq_get(cat->prods, PgfProduction, i);
|
|
||||||
pgf_lzr_index(lzr, cat, prod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GuMapItor fn;
|
GuMapItor fn;
|
||||||
PgfLzr* lzr;
|
PgfLzr* lzr;
|
||||||
@@ -229,19 +215,18 @@ static void
|
|||||||
pgf_lzr_index_cnccat_cb(GuMapItor* fn, const void* key, void* value,
|
pgf_lzr_index_cnccat_cb(GuMapItor* fn, const void* key, void* value,
|
||||||
GuExn* err)
|
GuExn* err)
|
||||||
{
|
{
|
||||||
(void) (key && err);
|
|
||||||
PgfLzrIndexFn* clo = (PgfLzrIndexFn*) fn;
|
PgfLzrIndexFn* clo = (PgfLzrIndexFn*) fn;
|
||||||
PgfCncCat** cnccatp = value;
|
PgfCCat *ccat = *((PgfCCat **) value);
|
||||||
PgfCncCat* cnccat = *cnccatp;
|
|
||||||
gu_enter("-> cnccat: %s", cnccat->cid);
|
gu_debug("ccat: %d", ccat->fid);
|
||||||
int n_ccats = gu_list_length(cnccat->cats);
|
if (gu_seq_is_null(ccat->prods)) {
|
||||||
for (int i = 0; i < n_ccats; i++) {
|
return;
|
||||||
PgfCCat* cat = gu_list_index(cnccat->cats, i);
|
}
|
||||||
if (cat) {
|
size_t n_prods = gu_seq_length(ccat->prods);
|
||||||
pgf_lzr_index_ccat(clo->lzr, cat);
|
for (size_t i = 0; i < n_prods; i++) {
|
||||||
}
|
PgfProduction prod = gu_seq_get(ccat->prods, PgfProduction, i);
|
||||||
|
pgf_lzr_index(clo->lzr, ccat, prod);
|
||||||
}
|
}
|
||||||
gu_exit("<-");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -254,12 +239,7 @@ pgf_new_lzr(PgfConcr* cnc, GuPool* pool)
|
|||||||
lzr->fun_indices = gu_map_type_new(PgfFunIndices, pool);
|
lzr->fun_indices = gu_map_type_new(PgfFunIndices, pool);
|
||||||
lzr->coerce_idx = gu_map_type_new(PgfCoerceIdx, pool);
|
lzr->coerce_idx = gu_map_type_new(PgfCoerceIdx, pool);
|
||||||
PgfLzrIndexFn clo = { { pgf_lzr_index_cnccat_cb }, lzr };
|
PgfLzrIndexFn clo = { { pgf_lzr_index_cnccat_cb }, lzr };
|
||||||
gu_map_iter(cnc->cnccats, &clo.fn, NULL);
|
gu_map_iter(cnc->ccats, &clo.fn, NULL);
|
||||||
size_t n_extras = gu_seq_length(cnc->extra_ccats);
|
|
||||||
for (size_t i = 0; i < n_extras; i++) {
|
|
||||||
PgfCCat* cat = gu_seq_get(cnc->extra_ccats, PgfCCat*, i);
|
|
||||||
pgf_lzr_index_ccat(lzr, cat);
|
|
||||||
}
|
|
||||||
// TODO: prune productions with zero linearizations
|
// TODO: prune productions with zero linearizations
|
||||||
return lzr;
|
return lzr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -597,13 +597,8 @@ static GU_DEFINE_TYPE(PgfCCatMap, GuIntMap, gu_ptr_type(PgfCCat),
|
|||||||
static GU_DEFINE_TYPE(PgfCncCatMap, GuStringMap, gu_ptr_type(PgfCncCat),
|
static GU_DEFINE_TYPE(PgfCncCatMap, GuStringMap, gu_ptr_type(PgfCncCat),
|
||||||
&gu_null_struct);
|
&gu_null_struct);
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
GuMapItor fn;
|
|
||||||
GuBuf* seq;
|
|
||||||
} PgfCCatCbCtx;
|
|
||||||
|
|
||||||
static PgfCncCat*
|
static PgfCncCat*
|
||||||
pgf_ccat_set_cnccat(PgfCCat* ccat, GuBuf* newly_set)
|
pgf_ccat_set_cnccat(PgfCCat* ccat)
|
||||||
{
|
{
|
||||||
if (!ccat->cnccat) {
|
if (!ccat->cnccat) {
|
||||||
size_t n_prods = gu_seq_length(ccat->prods);
|
size_t n_prods = gu_seq_length(ccat->prods);
|
||||||
@@ -615,8 +610,7 @@ pgf_ccat_set_cnccat(PgfCCat* ccat, GuBuf* newly_set)
|
|||||||
case PGF_PRODUCTION_COERCE: {
|
case PGF_PRODUCTION_COERCE: {
|
||||||
PgfProductionCoerce* pcoerce = i.data;
|
PgfProductionCoerce* pcoerce = i.data;
|
||||||
PgfCncCat* cnccat =
|
PgfCncCat* cnccat =
|
||||||
pgf_ccat_set_cnccat(pcoerce->coerce,
|
pgf_ccat_set_cnccat(pcoerce->coerce);
|
||||||
newly_set);
|
|
||||||
if (!ccat->cnccat) {
|
if (!ccat->cnccat) {
|
||||||
ccat->cnccat = cnccat;
|
ccat->cnccat = cnccat;
|
||||||
} else if (ccat->cnccat != cnccat) {
|
} else if (ccat->cnccat != cnccat) {
|
||||||
@@ -634,7 +628,6 @@ pgf_ccat_set_cnccat(PgfCCat* ccat, GuBuf* newly_set)
|
|||||||
gu_impossible();
|
gu_impossible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gu_buf_push(newly_set, PgfCCat*, ccat);
|
|
||||||
}
|
}
|
||||||
return ccat->cnccat;
|
return ccat->cnccat;
|
||||||
}
|
}
|
||||||
@@ -644,9 +637,8 @@ static void
|
|||||||
pgf_read_ccat_cb(GuMapItor* fn, const void* key, void* value, GuExn* err)
|
pgf_read_ccat_cb(GuMapItor* fn, const void* key, void* value, GuExn* err)
|
||||||
{
|
{
|
||||||
(void) (key && err);
|
(void) (key && err);
|
||||||
PgfCCatCbCtx* ctx = (PgfCCatCbCtx*) fn;
|
|
||||||
PgfCCat** ccatp = value;
|
PgfCCat** ccatp = value;
|
||||||
pgf_ccat_set_cnccat(*ccatp, ctx->seq);
|
pgf_ccat_set_cnccat(*ccatp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void*
|
static void*
|
||||||
@@ -673,12 +665,10 @@ pgf_read_new_PgfConcr(GuType* type, PgfReader* rdr, GuPool* pool,
|
|||||||
pgf_read_into_map(ccats_t, rdr, concr->ccats, rdr->opool);
|
pgf_read_into_map(ccats_t, rdr, concr->ccats, rdr->opool);
|
||||||
concr->cnccats = pgf_read_new(rdr, gu_type(PgfCncCatMap),
|
concr->cnccats = pgf_read_new(rdr, gu_type(PgfCncCatMap),
|
||||||
rdr->opool, NULL);
|
rdr->opool, NULL);
|
||||||
|
|
||||||
GuBuf* extra_ccats = gu_new_buf(PgfCCat*, pool);
|
|
||||||
PgfCCatCbCtx ctx = { { pgf_read_ccat_cb }, extra_ccats };
|
|
||||||
gu_map_iter(concr->ccats, &ctx.fn, NULL);
|
|
||||||
concr->extra_ccats = gu_buf_freeze(extra_ccats, rdr->opool);
|
|
||||||
concr->max_fid = pgf_read_int(rdr);
|
concr->max_fid = pgf_read_int(rdr);
|
||||||
|
|
||||||
|
GuMapItor fn = { pgf_read_ccat_cb };
|
||||||
|
gu_map_iter(concr->ccats, &fn, NULL);
|
||||||
return concr;
|
return concr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user