tabular linearization in the C and Java runtimes

This commit is contained in:
kr.angelov
2013-10-23 14:49:28 +00:00
parent 51bf4e0380
commit 0882396875
6 changed files with 103 additions and 1 deletions

View File

@@ -128,7 +128,6 @@ typedef struct {
extern GU_DECLARE_TYPE(PgfCncCat, abstract);
typedef GuString PgfToken;
typedef GuSeq PgfTokens;
bool

View File

@@ -677,6 +677,35 @@ pgf_lzr_linearize_simple(PgfConcr* concr, PgfCncTree ctree,
pgf_lzr_linearize(concr, ctree, lin_idx, &flin.funcs);
}
void
pgf_lzr_linearize_table(PgfConcr* concr, PgfCncTree ctree,
size_t* n_lins, GuString** labels)
{
static GuString s_label = "s";
GuVariantInfo cti = gu_variant_open(ctree);
switch (cti.tag) {
case PGF_CNC_TREE_APP: {
PgfCncTreeApp* fapp = cti.data;
PgfCncCat* cnccat =
gu_map_get(concr->cnccats, fapp->fun->absfun->type->cid, PgfCncCat*);
*n_lins = cnccat->n_lins;
*labels = cnccat->labels;
break;
}
case PGF_CNC_TREE_LIT:
case PGF_CNC_TREE_CHUNKS: {
*n_lins = 1;
*labels = &s_label;
break;
}
default:
gu_impossible();
}
}
GuString
pgf_get_tokens(PgfSymbols* syms, uint16_t sym_idx, GuPool* pool)
{

View File

@@ -71,6 +71,11 @@ pgf_lzr_linearize(PgfConcr* concr, PgfCncTree ctree, size_t lin_idx,
void
pgf_lzr_linearize_simple(PgfConcr* concr, PgfCncTree ctree,
size_t lin_idx, GuOut* out, GuExn* err);
void
pgf_lzr_linearize_table(PgfConcr* concr, PgfCncTree ctree,
size_t* n_lins, GuString** labels);
#endif
#ifdef PGF_PARSER_H_

View File

@@ -35,6 +35,7 @@
typedef GuString PgfCId;
extern GU_DECLARE_TYPE(PgfCId, typedef);
typedef GuString PgfToken;
extern GU_DECLARE_TYPE(PgfExn, abstract);
extern GU_DECLARE_TYPE(PgfParseError, abstract);