summaryrefslogtreecommitdiff
path: root/src/runtime/c/pgf
diff options
context:
space:
mode:
authorKrasimir Angelov <kr.angelov@gmail.com>2017-09-01 09:57:00 +0200
committerKrasimir Angelov <kr.angelov@gmail.com>2017-09-01 09:57:00 +0200
commitd5a7945ba0b082a3be8a7cd4b9142e553dbfec9b (patch)
treebb3387c734a154856888f0a7712e11e2a3662aea /src/runtime/c/pgf
parent1a27ddfabbbf7b8ef7449ad0bdd14baf8d76c341 (diff)
complete details for the "ai" command in the C shell
Diffstat (limited to 'src/runtime/c/pgf')
-rw-r--r--src/runtime/c/pgf/expr.c24
-rw-r--r--src/runtime/c/pgf/expr.h4
2 files changed, 28 insertions, 0 deletions
diff --git a/src/runtime/c/pgf/expr.c b/src/runtime/c/pgf/expr.c
index c1f803385..4e9f5ca89 100644
--- a/src/runtime/c/pgf/expr.c
+++ b/src/runtime/c/pgf/expr.c
@@ -1467,6 +1467,30 @@ 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)
{
diff --git a/src/runtime/c/pgf/expr.h b/src/runtime/c/pgf/expr.h
index 7f8746b28..e28db7f31 100644
--- a/src/runtime/c/pgf/expr.h
+++ b/src/runtime/c/pgf/expr.h
@@ -226,6 +226,10 @@ 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_compute_tree_probability(PgfPGF *gr, PgfExpr expr);