mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-20 02:09:32 -06:00
in the PGF2 api: remove showCategory. add categoryContext and functionIsConstructor
This commit is contained in:
@@ -1720,30 +1720,6 @@ pgf_print_expr_tuple(size_t n_exprs, PgfExpr exprs[], PgfPrintContext* ctxt,
|
||||
gu_putc('>', out, err);
|
||||
}
|
||||
|
||||
PGF_API_DECL void
|
||||
pgf_print_category(PgfPGF *gr, PgfCId catname,
|
||||
GuOut* out, GuExn *err)
|
||||
{
|
||||
PgfAbsCat* abscat =
|
||||
gu_seq_binsearch(gr->abstract.cats, pgf_abscat_order, PgfAbsCat, catname);
|
||||
if (abscat == NULL) {
|
||||
GuExnData* exn = gu_raise(err, PgfExn);
|
||||
exn->data = "Unknown category";
|
||||
return;
|
||||
}
|
||||
|
||||
gu_puts(abscat->name, out, err);
|
||||
|
||||
PgfPrintContext* ctxt = NULL;
|
||||
size_t n_hypos = gu_seq_length(abscat->context);
|
||||
for (size_t i = 0; i < n_hypos; i++) {
|
||||
PgfHypo *hypo = gu_seq_index(abscat->context, PgfHypo, i);
|
||||
|
||||
gu_putc(' ', out, err);
|
||||
ctxt = pgf_print_hypo(hypo, ctxt, 4, out, err);
|
||||
}
|
||||
}
|
||||
|
||||
PGF_API bool
|
||||
pgf_type_eq(PgfType* t1, PgfType* t2)
|
||||
{
|
||||
|
||||
@@ -238,11 +238,7 @@ PGF_API_DECL void
|
||||
pgf_print_expr_tuple(size_t n_exprs, PgfExpr exprs[], PgfPrintContext* ctxt,
|
||||
GuOut* out, GuExn* err);
|
||||
|
||||
PGF_API_DECL void
|
||||
pgf_print_category(PgfPGF *gr, PgfCId catname,
|
||||
GuOut* out, GuExn *err);
|
||||
|
||||
PGF_API prob_t
|
||||
PGF_API_DECL prob_t
|
||||
pgf_compute_tree_probability(PgfPGF *gr, PgfExpr expr);
|
||||
|
||||
#endif /* EXPR_H_ */
|
||||
|
||||
@@ -140,6 +140,18 @@ pgf_start_cat(PgfPGF* pgf, GuPool* pool)
|
||||
return type;
|
||||
}
|
||||
|
||||
PGF_API PgfHypos*
|
||||
pgf_category_context(PgfPGF *gr, PgfCId catname)
|
||||
{
|
||||
PgfAbsCat* abscat =
|
||||
gu_seq_binsearch(gr->abstract.cats, pgf_abscat_order, PgfAbsCat, catname);
|
||||
if (abscat == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return abscat->context;
|
||||
}
|
||||
|
||||
PGF_API GuString
|
||||
pgf_language_code(PgfConcr* concr)
|
||||
{
|
||||
@@ -173,7 +185,7 @@ pgf_iter_functions(PgfPGF* pgf, GuMapItor* itor, GuExn* err)
|
||||
}
|
||||
|
||||
PGF_API void
|
||||
pgf_iter_functions_by_cat(PgfPGF* pgf, PgfCId catname,
|
||||
pgf_iter_functions_by_cat(PgfPGF* pgf, PgfCId catname,
|
||||
GuMapItor* itor, GuExn* err)
|
||||
{
|
||||
size_t n_funs = gu_seq_length(pgf->abstract.funs);
|
||||
@@ -199,6 +211,16 @@ pgf_function_type(PgfPGF* pgf, PgfCId funname)
|
||||
return absfun->type;
|
||||
}
|
||||
|
||||
PGF_API_DECL bool
|
||||
pgf_function_is_constructor(PgfPGF* pgf, PgfCId funname)
|
||||
{
|
||||
PgfAbsFun* absfun =
|
||||
gu_seq_binsearch(pgf->abstract.funs, pgf_absfun_order, PgfAbsFun, funname);
|
||||
if (absfun == NULL)
|
||||
return false;
|
||||
return (absfun->defns == NULL);
|
||||
}
|
||||
|
||||
PGF_API double
|
||||
pgf_function_prob(PgfPGF* pgf, PgfCId funname)
|
||||
{
|
||||
|
||||
@@ -81,6 +81,9 @@ pgf_iter_categories(PgfPGF* pgf, GuMapItor* itor, GuExn* err);
|
||||
PGF_API_DECL PgfType*
|
||||
pgf_start_cat(PgfPGF* pgf, GuPool* pool);
|
||||
|
||||
PGF_API_DECL PgfHypos*
|
||||
pgf_category_context(PgfPGF *gr, PgfCId catname);
|
||||
|
||||
PGF_API_DECL void
|
||||
pgf_iter_functions(PgfPGF* pgf, GuMapItor* itor, GuExn* err);
|
||||
|
||||
@@ -91,6 +94,9 @@ pgf_iter_functions_by_cat(PgfPGF* pgf, PgfCId catname,
|
||||
PGF_API_DECL PgfType*
|
||||
pgf_function_type(PgfPGF* pgf, PgfCId funname);
|
||||
|
||||
PGF_API_DECL bool
|
||||
pgf_function_is_constructor(PgfPGF* pgf, PgfCId funname);
|
||||
|
||||
PGF_API_DECL double
|
||||
pgf_function_prob(PgfPGF* pgf, PgfCId funname);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user