basic linearization is working

This commit is contained in:
krangelov
2021-11-30 17:54:36 +01:00
parent ae08d42d6e
commit 9ed74d7772
4 changed files with 335 additions and 24 deletions

View File

@@ -1,6 +1,27 @@
#ifndef LINEARIZER_H
#define LINEARIZER_H
class PGF_INTERNAL_DECL PgfLinearizationOutput : public PgfLinearizationOutputIface {
PgfPrinter printer;
bool bind;
bool capit;
bool allcapit;
public:
PgfLinearizationOutput();
PgfText *get_text() { return printer.get_text(); };
virtual void symbol_token(PgfText *tok);
virtual void begin_phrase(PgfText *cat, int fid, PgfText *ann, PgfText *fun);
virtual void end_phrase(PgfText *cat, int fid, PgfText *ann, PgfText *fun);
virtual void symbol_ne();
virtual void symbol_bind();
virtual void symbol_capit();
virtual void symbol_allcapit();
virtual void symbol_meta(PgfMetaId id);
};
class PGF_INTERNAL_DECL PgfLinearizer : public PgfUnmarshaller {
ref<PgfConcr> concr;
PgfMarshaller *m;
@@ -11,32 +32,30 @@ class PGF_INTERNAL_DECL PgfLinearizer : public PgfUnmarshaller {
TreeNode *args;
ref<PgfConcrLin> lin;
size_t lin_index;
TreeNode(PgfLinearizer *linearizer, ref<PgfConcrLin> lin) {
this->next = linearizer->root;
this->next_arg = NULL;
this->args = linearizer->args;
this->lin = lin;
size_t value;
size_t var_count;
size_t *var_values;
if (linearizer->first == NULL)
linearizer->first = this;
linearizer->root = this;
}
TreeNode(PgfLinearizer *linearizer, ref<PgfConcrLin> lin);
size_t eval_param(PgfLParam *param);
};
TreeNode *root;
TreeNode *first;
TreeNode *args;
void linearize(PgfLinearizationOutputIface *out, TreeNode *node, ref<Vector<PgfSymbol>> syms);
void linearize(PgfLinearizationOutputIface *out, TreeNode *node, size_t lindex);
public:
PgfLinearizer(ref<PgfConcr> concr, PgfMarshaller *m) {
this->concr = concr;
this->m = m;
this->root = NULL;
this->first = NULL;
this->args = NULL;
};
PgfLinearizer(ref<PgfConcr> concr, PgfMarshaller *m);
bool resolve();
void linearize(PgfLinearizationOutputIface *out) {
linearize(out, root, 0);
}
~PgfLinearizer();