mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-09 03:02:50 -06:00
basic linearization is working
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user