summaryrefslogtreecommitdiff
path: root/src/runtime/c
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-10-23 14:49:28 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-10-23 14:49:28 +0000
commit0882396875e26995ef996890e022acc3662eb70f (patch)
tree4dc9f71182a482f5281f587a167f2cf8505ab129 /src/runtime/c
parent51bf4e0380899ca350a002b2c5ee840e61d16b33 (diff)
tabular linearization in the C and Java runtimes
Diffstat (limited to 'src/runtime/c')
-rw-r--r--src/runtime/c/pgf/data.h1
-rw-r--r--src/runtime/c/pgf/linearizer.c29
-rw-r--r--src/runtime/c/pgf/linearizer.h5
-rw-r--r--src/runtime/c/pgf/pgf.h1
4 files changed, 35 insertions, 1 deletions
diff --git a/src/runtime/c/pgf/data.h b/src/runtime/c/pgf/data.h
index 0dae42491..163d45d95 100644
--- a/src/runtime/c/pgf/data.h
+++ b/src/runtime/c/pgf/data.h
@@ -128,7 +128,6 @@ typedef struct {
extern GU_DECLARE_TYPE(PgfCncCat, abstract);
-typedef GuString PgfToken;
typedef GuSeq PgfTokens;
bool
diff --git a/src/runtime/c/pgf/linearizer.c b/src/runtime/c/pgf/linearizer.c
index 0465b6e1c..9a57de5fc 100644
--- a/src/runtime/c/pgf/linearizer.c
+++ b/src/runtime/c/pgf/linearizer.c
@@ -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)
{
diff --git a/src/runtime/c/pgf/linearizer.h b/src/runtime/c/pgf/linearizer.h
index 1cc244575..65c02c48b 100644
--- a/src/runtime/c/pgf/linearizer.h
+++ b/src/runtime/c/pgf/linearizer.h
@@ -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_
diff --git a/src/runtime/c/pgf/pgf.h b/src/runtime/c/pgf/pgf.h
index b586eb7b0..9ec63c4d6 100644
--- a/src/runtime/c/pgf/pgf.h
+++ b/src/runtime/c/pgf/pgf.h
@@ -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);