forked from GitHub/gf-core
libpgf: move the lindefs field from PgfCncCat to PgfCCat. display the list in the grammar printout
This commit is contained in:
@@ -4,11 +4,10 @@
|
|||||||
#include <gu/variant.h>
|
#include <gu/variant.h>
|
||||||
#include <gu/assert.h>
|
#include <gu/assert.h>
|
||||||
|
|
||||||
|
PgfCCat pgf_ccat_string = { NULL, NULL, GU_NULL_SEQ, -1 };
|
||||||
PgfCCat pgf_ccat_string = { NULL, GU_NULL_SEQ, -1 };
|
PgfCCat pgf_ccat_int = { NULL, NULL, GU_NULL_SEQ, -2 };
|
||||||
PgfCCat pgf_ccat_int = { NULL, GU_NULL_SEQ, -2 };
|
PgfCCat pgf_ccat_float = { NULL, NULL, GU_NULL_SEQ, -3 };
|
||||||
PgfCCat pgf_ccat_float = { NULL, GU_NULL_SEQ, -3 };
|
PgfCCat pgf_ccat_var = { NULL, NULL, GU_NULL_SEQ, -4 };
|
||||||
PgfCCat pgf_ccat_var = { NULL, GU_NULL_SEQ, -4 };
|
|
||||||
|
|
||||||
PgfCCatId
|
PgfCCatId
|
||||||
pgf_literal_cat(PgfLiteral lit)
|
pgf_literal_cat(PgfLiteral lit)
|
||||||
@@ -59,6 +58,7 @@ typedef GuType_GuStringMap GuType_PgfCIdMap;
|
|||||||
|
|
||||||
GU_DEFINE_TYPE(PgfCCat, struct,
|
GU_DEFINE_TYPE(PgfCCat, struct,
|
||||||
GU_MEMBER_S(PgfCCat, cnccat, PgfCncCat),
|
GU_MEMBER_S(PgfCCat, cnccat, PgfCncCat),
|
||||||
|
GU_MEMBER_P(PgfCCat, lindefs, PgfFunIds),
|
||||||
GU_MEMBER(PgfCCat, prods, PgfProductionSeq));
|
GU_MEMBER(PgfCCat, prods, PgfProductionSeq));
|
||||||
|
|
||||||
GU_DEFINE_TYPE(PgfCCatId, shared, gu_type(PgfCCat));
|
GU_DEFINE_TYPE(PgfCCatId, shared, gu_type(PgfCCat));
|
||||||
@@ -100,7 +100,6 @@ GU_DEFINE_TYPE(
|
|||||||
GU_MEMBER(PgfCncCat, cid, PgfCId),
|
GU_MEMBER(PgfCncCat, cid, PgfCId),
|
||||||
GU_MEMBER_P(PgfCncCat, cats, PgfCCatIds),
|
GU_MEMBER_P(PgfCncCat, cats, PgfCCatIds),
|
||||||
GU_MEMBER(PgfCncCat, n_lins, size_t),
|
GU_MEMBER(PgfCncCat, n_lins, size_t),
|
||||||
GU_MEMBER_P(PgfCncCat, lindefs, PgfFunIds),
|
|
||||||
GU_MEMBER_P(PgfCncCat, labels, GuStringL));
|
GU_MEMBER_P(PgfCncCat, labels, GuStringL));
|
||||||
|
|
||||||
// GU_DEFINE_TYPE(PgfSequence, GuList, gu_ptr_type(PgfSymbol));
|
// GU_DEFINE_TYPE(PgfSequence, GuList, gu_ptr_type(PgfSymbol));
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ struct PgfCat {
|
|||||||
struct PgfCncCat {
|
struct PgfCncCat {
|
||||||
PgfCId cid;
|
PgfCId cid;
|
||||||
PgfCCatIds* cats;
|
PgfCCatIds* cats;
|
||||||
PgfFunIds* lindefs;
|
|
||||||
size_t n_lins;
|
size_t n_lins;
|
||||||
|
|
||||||
GuStringL* labels;
|
GuStringL* labels;
|
||||||
@@ -173,6 +172,7 @@ struct PgfAlternative {
|
|||||||
|
|
||||||
struct PgfCCat {
|
struct PgfCCat {
|
||||||
PgfCncCat* cnccat;
|
PgfCncCat* cnccat;
|
||||||
|
PgfFunIds* lindefs;
|
||||||
PgfProductionSeq prods;
|
PgfProductionSeq prods;
|
||||||
int fid;
|
int fid;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -437,6 +437,7 @@ pgf_read_to_PgfCCatId(GuType* type, PgfReader* rdr, void* to)
|
|||||||
if (!ccat) {
|
if (!ccat) {
|
||||||
ccat = gu_new(PgfCCat, rdr->pool);
|
ccat = gu_new(PgfCCat, rdr->pool);
|
||||||
ccat->cnccat = NULL;
|
ccat->cnccat = NULL;
|
||||||
|
ccat->lindefs = gu_map_get(rdr->curr_lindefs, &fid, PgfFunIds*);
|
||||||
ccat->prods = gu_null_seq;
|
ccat->prods = gu_null_seq;
|
||||||
ccat->fid = fid;
|
ccat->fid = fid;
|
||||||
|
|
||||||
@@ -449,14 +450,16 @@ pgf_read_to_PgfCCatId(GuType* type, PgfReader* rdr, void* to)
|
|||||||
static void
|
static void
|
||||||
pgf_read_to_PgfCCat(GuType* type, PgfReader* rdr, void* to)
|
pgf_read_to_PgfCCat(GuType* type, PgfReader* rdr, void* to)
|
||||||
{
|
{
|
||||||
(void) type;
|
(void) type;
|
||||||
gu_enter("->");
|
gu_enter("->");
|
||||||
PgfCCat* cat = to;
|
int* fidp = rdr->curr_key;
|
||||||
cat->cnccat = NULL;
|
|
||||||
pgf_read_to(rdr, gu_type(PgfProductionSeq), &cat->prods);
|
PgfCCat* ccat = to;
|
||||||
int* fidp = rdr->curr_key;
|
ccat->cnccat = NULL;
|
||||||
cat->fid = *fidp;
|
ccat->lindefs = gu_map_get(rdr->curr_lindefs, fidp, PgfFunIds*);
|
||||||
gu_exit("<-");
|
pgf_read_to(rdr, gu_type(PgfProductionSeq), &ccat->prods);
|
||||||
|
ccat->fid = *fidp;
|
||||||
|
gu_exit("<-");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is only needed because new_struct would otherwise override.
|
// This is only needed because new_struct would otherwise override.
|
||||||
@@ -736,6 +739,7 @@ pgf_read_new_PgfCncCat(GuType* type, PgfReader* rdr, GuPool* pool,
|
|||||||
if (!ccat) {
|
if (!ccat) {
|
||||||
ccat = gu_new(PgfCCat, rdr->pool);
|
ccat = gu_new(PgfCCat, rdr->pool);
|
||||||
ccat->cnccat = NULL;
|
ccat->cnccat = NULL;
|
||||||
|
ccat->lindefs = gu_map_get(rdr->curr_lindefs, &fid, PgfFunIds*);
|
||||||
ccat->prods = gu_null_seq;
|
ccat->prods = gu_null_seq;
|
||||||
ccat->fid = fid;
|
ccat->fid = fid;
|
||||||
|
|
||||||
@@ -752,7 +756,6 @@ pgf_read_new_PgfCncCat(GuType* type, PgfReader* rdr, GuPool* pool,
|
|||||||
}
|
}
|
||||||
cnccat->n_lins = n_lins == -1 ? 0 : (size_t) n_lins;
|
cnccat->n_lins = n_lins == -1 ? 0 : (size_t) n_lins;
|
||||||
cnccat->cats = cats;
|
cnccat->cats = cats;
|
||||||
cnccat->lindefs = gu_map_get(rdr->curr_lindefs, &first, PgfFunIds*);
|
|
||||||
cnccat->labels = pgf_read_new(rdr, gu_type(GuStringL),
|
cnccat->labels = pgf_read_new(rdr, gu_type(GuStringL),
|
||||||
pool, NULL);
|
pool, NULL);
|
||||||
gu_exit("<-");
|
gu_exit("<-");
|
||||||
|
|||||||
Reference in New Issue
Block a user