mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
provide API to access the language code for the concrete language
This commit is contained in:
@@ -145,6 +145,29 @@ pgf_start_cat(PgfPGF* pgf, GuPool* pool)
|
|||||||
return gu_str_string("S", pool);
|
return gu_str_string("S", pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuString
|
||||||
|
pgf_language_code(PgfConcr* concr)
|
||||||
|
{
|
||||||
|
GuPool* tmp_pool = gu_local_pool();
|
||||||
|
|
||||||
|
GuString s = gu_str_string("language", tmp_pool);
|
||||||
|
PgfLiteral lit =
|
||||||
|
gu_map_get(concr->cflags, &s, PgfLiteral);
|
||||||
|
|
||||||
|
if (gu_variant_is_null(lit))
|
||||||
|
return gu_empty_string;
|
||||||
|
|
||||||
|
GuVariantInfo i = gu_variant_open(lit);
|
||||||
|
switch (i.tag) {
|
||||||
|
case PGF_LITERAL_STR: {
|
||||||
|
PgfLiteralStr *lstr = (PgfLiteralStr *) i.data;
|
||||||
|
return lstr->val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return gu_empty_string;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pgf_iter_functions(PgfPGF* pgf, GuMapItor* fn, GuExn* err)
|
pgf_iter_functions(PgfPGF* pgf, GuMapItor* fn, GuExn* err)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ pgf_get_language(PgfPGF*, PgfCId lang);
|
|||||||
GuString
|
GuString
|
||||||
pgf_concrete_name(PgfConcr*);
|
pgf_concrete_name(PgfConcr*);
|
||||||
|
|
||||||
|
GuString
|
||||||
|
pgf_language_code(PgfConcr* concr);
|
||||||
|
|
||||||
void
|
void
|
||||||
pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err);
|
pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err);
|
||||||
|
|
||||||
|
|||||||
@@ -1654,6 +1654,12 @@ Concr_getName(ConcrObject *self, void *closure)
|
|||||||
return gu2py_string(pgf_concrete_name(self->concr));
|
return gu2py_string(pgf_concrete_name(self->concr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
Concr_getLanguageCode(ConcrObject *self, void *closure)
|
||||||
|
{
|
||||||
|
return gu2py_string(pgf_language_code(self->concr));
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
Concr_graphvizParseTree(ConcrObject* self, PyObject *args) {
|
Concr_graphvizParseTree(ConcrObject* self, PyObject *args) {
|
||||||
ExprObject* pyexpr;
|
ExprObject* pyexpr;
|
||||||
@@ -1683,6 +1689,10 @@ static PyGetSetDef Concr_getseters[] = {
|
|||||||
(getter)Concr_getName, NULL,
|
(getter)Concr_getName, NULL,
|
||||||
"the name of the concrete syntax",
|
"the name of the concrete syntax",
|
||||||
},
|
},
|
||||||
|
{"languageCode",
|
||||||
|
(getter)Concr_getLanguageCode, NULL,
|
||||||
|
"the language code for this concrete syntax",
|
||||||
|
},
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user