added exprProbability

This commit is contained in:
krangelov
2021-09-14 17:33:22 +02:00
parent 05813384e0
commit e82fb7f32f
6 changed files with 143 additions and 1 deletions

View File

@@ -439,6 +439,24 @@ PgfExpr pgf_read_expr_ex(PgfText *input, const char **end_pos, PgfUnmarshaller *
return expr;
}
PGF_API
prob_t pgf_expr_prob(PgfDB *db, PgfRevision revision,
PgfExpr e,
PgfMarshaller *m,
PgfExn *err)
{
PGF_API_BEGIN {
DB_scope scope(db, READER_SCOPE);
ref<PgfPGF> pgf = PgfDB::revision2pgf(revision);
PgfExprProbEstimator estimator(pgf, m);
m->match_expr(&estimator, e);
return estimator.get_prob();
} PGF_API_END
return 0;
}
PGF_API
PgfText *pgf_print_type(PgfType ty,
PgfPrintContext *ctxt, int prio,