restore graphvizParseTree

This commit is contained in:
krangelov
2021-12-04 14:12:23 +01:00
parent bbff79aaa3
commit 3d1123eed4
6 changed files with 80 additions and 6 deletions

View File

@@ -23,6 +23,8 @@ libpgf_la_SOURCES = \
pgf/typechecker.h \
pgf/linearizer.cxx \
pgf/linearizer.h \
pgf/graphviz.cxx \
pgf/graphviz.h \
pgf/data.cxx \
pgf/data.h \
pgf/expr.cxx \

View File

@@ -11,6 +11,7 @@
#include "printer.h"
#include "typechecker.h"
#include "linearizer.h"
#include "graphviz.h"
static void
pgf_exn_clear(PgfExn* err)
@@ -2065,3 +2066,27 @@ void pgf_set_concrete_flag(PgfDB *db, PgfConcrRevision revision,
concr->cflags = cflags;
} PGF_API_END
}
PGF_API PgfText *
pgf_graphviz_parse_tree(PgfDB *db, PgfConcrRevision revision,
PgfExpr expr, PgfMarshaller *m,
PgfGraphvizOptions* opts,
PgfExn *err)
{
PGF_API_BEGIN {
DB_scope scope(db, READER_SCOPE);
ref<PgfConcr> concr = PgfDB::revision2concr(revision);
PgfLinearizationGraphvizOutput out;
PgfLinearizer linearizer(concr, m);
m->match_expr(&linearizer, expr);
linearizer.reverse_and_label();
if (linearizer.resolve()) {
linearizer.linearize(&out);
return out.generate_graphviz(opts);
}
} PGF_API_END
return NULL;
}

View File

@@ -672,4 +672,23 @@ void pgf_set_concrete_flag(PgfDB *db, PgfConcrRevision revision,
PgfMarshaller *m,
PgfExn *err);
typedef struct {
int noLeaves;
int noFun;
int noCat;
int noDep;
const char *nodeFont;
const char *leafFont;
const char *nodeColor;
const char *leafColor;
const char *nodeEdgeStyle;
const char *leafEdgeStyle;
} PgfGraphvizOptions;
PGF_API PgfText *
pgf_graphviz_parse_tree(PgfDB *db, PgfConcrRevision revision,
PgfExpr expr, PgfMarshaller *m,
PgfGraphvizOptions* opts,
PgfExn *err);
#endif // PGF_H_