mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 17:12:50 -06:00
further extend the API of the C runtime
This commit is contained in:
@@ -1650,10 +1650,10 @@ pgf_print_hypo(PgfHypo *hypo, PgfPrintContext* ctxt, int prec,
|
||||
} else {
|
||||
pgf_print_type(hypo->type, ctxt, prec, out, err);
|
||||
}
|
||||
|
||||
|
||||
gu_pool_free(tmp_pool);
|
||||
}
|
||||
|
||||
|
||||
PgfPrintContext* new_ctxt = malloc(sizeof(PgfPrintContext));
|
||||
new_ctxt->name = hypo->cid;
|
||||
new_ctxt->next = ctxt;
|
||||
@@ -1668,7 +1668,7 @@ pgf_print_type(PgfType *type, PgfPrintContext* ctxt, int prec,
|
||||
|
||||
if (n_hypos > 0) {
|
||||
if (prec > 0) gu_putc('(', out, err);
|
||||
|
||||
|
||||
PgfPrintContext* new_ctxt = ctxt;
|
||||
for (size_t i = 0; i < n_hypos; i++) {
|
||||
PgfHypo *hypo = gu_seq_index(type->hypos, PgfHypo, i);
|
||||
@@ -1707,6 +1707,22 @@ pgf_print_type(PgfType *type, PgfPrintContext* ctxt, int prec,
|
||||
}
|
||||
}
|
||||
|
||||
PGF_API void
|
||||
pgf_print_context(PgfHypos *hypos, PgfPrintContext* ctxt,
|
||||
GuOut *out, GuExn *err)
|
||||
{
|
||||
PgfPrintContext* new_ctxt = ctxt;
|
||||
|
||||
size_t n_hypos = gu_seq_length(hypos);
|
||||
for (size_t i = 0; i < n_hypos; i++) {
|
||||
if (i > 0)
|
||||
gu_putc(' ', out, err);
|
||||
|
||||
PgfHypo *hypo = gu_seq_index(hypos, PgfHypo, i);
|
||||
new_ctxt = pgf_print_hypo(hypo, new_ctxt, 4, out, err);
|
||||
}
|
||||
}
|
||||
|
||||
PGF_API void
|
||||
pgf_print_expr_tuple(size_t n_exprs, PgfExpr exprs[], PgfPrintContext* ctxt,
|
||||
GuOut* out, GuExn* err)
|
||||
|
||||
@@ -234,6 +234,10 @@ PGF_API_DECL void
|
||||
pgf_print_type(PgfType *type, PgfPrintContext* ctxt, int prec,
|
||||
GuOut* out, GuExn *err);
|
||||
|
||||
PGF_API_DECL void
|
||||
pgf_print_context(PgfHypos *hypos, PgfPrintContext* ctxt,
|
||||
GuOut *out, GuExn *err);
|
||||
|
||||
PGF_API_DECL void
|
||||
pgf_print_expr_tuple(size_t n_exprs, PgfExpr exprs[], PgfPrintContext* ctxt,
|
||||
GuOut* out, GuExn* err);
|
||||
|
||||
@@ -152,6 +152,17 @@ pgf_category_context(PgfPGF *gr, PgfCId catname)
|
||||
return abscat->context;
|
||||
}
|
||||
|
||||
PGF_API prob_t
|
||||
pgf_category_prob(PgfPGF* pgf, PgfCId catname)
|
||||
{
|
||||
PgfAbsCat* abscat =
|
||||
gu_seq_binsearch(pgf->abstract.cats, pgf_abscat_order, PgfAbsCat, catname);
|
||||
if (abscat == NULL)
|
||||
return INFINITY;
|
||||
|
||||
return abscat->prob;
|
||||
}
|
||||
|
||||
PGF_API GuString
|
||||
pgf_language_code(PgfConcr* concr)
|
||||
{
|
||||
@@ -221,7 +232,7 @@ pgf_function_is_constructor(PgfPGF* pgf, PgfCId funname)
|
||||
return (absfun->defns == NULL);
|
||||
}
|
||||
|
||||
PGF_API double
|
||||
PGF_API prob_t
|
||||
pgf_function_prob(PgfPGF* pgf, PgfCId funname)
|
||||
{
|
||||
PgfAbsFun* absfun =
|
||||
|
||||
@@ -84,6 +84,9 @@ pgf_start_cat(PgfPGF* pgf, GuPool* pool);
|
||||
PGF_API_DECL PgfHypos*
|
||||
pgf_category_context(PgfPGF *gr, PgfCId catname);
|
||||
|
||||
PGF_API_DECL prob_t
|
||||
pgf_category_prob(PgfPGF* pgf, PgfCId catname);
|
||||
|
||||
PGF_API_DECL void
|
||||
pgf_iter_functions(PgfPGF* pgf, GuMapItor* itor, GuExn* err);
|
||||
|
||||
@@ -97,7 +100,7 @@ pgf_function_type(PgfPGF* pgf, PgfCId funname);
|
||||
PGF_API_DECL bool
|
||||
pgf_function_is_constructor(PgfPGF* pgf, PgfCId funname);
|
||||
|
||||
PGF_API_DECL double
|
||||
PGF_API_DECL prob_t
|
||||
pgf_function_prob(PgfPGF* pgf, PgfCId funname);
|
||||
|
||||
PGF_API_DECL GuString
|
||||
|
||||
Reference in New Issue
Block a user