From 1ca09448f9032b92ef436f4e0f658309d60e7ffd Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Thu, 10 Apr 2014 14:14:31 +0000 Subject: now fully functional Java API for custom literals --- src/runtime/c/pgf/pgf.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/runtime/c/pgf/pgf.c') diff --git a/src/runtime/c/pgf/pgf.c b/src/runtime/c/pgf/pgf.c index 155b93135..ee736616c 100644 --- a/src/runtime/c/pgf/pgf.c +++ b/src/runtime/c/pgf/pgf.c @@ -166,3 +166,35 @@ pgf_has_linearization(PgfConcr* concr, PgfCId id) gu_map_get(concr->fun_indices, id, PgfCncOverloadMap*); return (overl_table != NULL); } + +GuPool* +pgf_concr_get_pool(PgfConcr* concr) +{ + GuPool* pool = concr->pool; + if (pool == NULL) + pool = gu_container(concr->abstr, PgfPGF, abstract)->pool; + return pool; +} + +void +pgf_concr_add_literal(PgfConcr *concr, PgfCId cat, + PgfLiteralCallback* callback, + GuExn* err) +{ + if (concr->cnccats == NULL || + concr->callbacks == NULL) { + GuExnData* err_data = gu_raise(err, PgfExn); + if (err_data) { + err_data->data = "The concrete syntax is not loaded"; + return; + } + } + + PgfCncCat* cnccat = + gu_map_get(concr->cnccats, cat, PgfCncCat*); + if (cnccat == NULL) + return; + + gu_map_put(concr->callbacks, cnccat, + PgfLiteralCallback*, callback); +} -- cgit v1.2.3