summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-10-31 09:04:07 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-10-31 09:04:07 +0000
commit050ebd469ce942e98d20aa6a8f925bf465691ed6 (patch)
tree1ad0f367ac8a9bc9fcee4224fac9be176ecbb536 /src/runtime
parentfed16ca9e522b58ba7d7a4a4088b32144fcbbe23 (diff)
bracketedLinearize in Python is now using the linref
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/c/pgf/linearizer.h3
-rw-r--r--src/runtime/python/pypgf.c14
2 files changed, 5 insertions, 12 deletions
diff --git a/src/runtime/c/pgf/linearizer.h b/src/runtime/c/pgf/linearizer.h
index 65c02c48b..e483824b0 100644
--- a/src/runtime/c/pgf/linearizer.h
+++ b/src/runtime/c/pgf/linearizer.h
@@ -59,7 +59,8 @@ struct PgfLinFuncs
};
-
+PgfCncTree
+pgf_lzr_wrap_linref(PgfCncTree ctree, GuPool* pool);
/// Linearize a concrete syntax tree.
void
diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c
index d5d3e78b1..21db6741a 100644
--- a/src/runtime/python/pypgf.c
+++ b/src/runtime/python/pypgf.c
@@ -1492,6 +1492,8 @@ Concr_bracketedLinearize(ConcrObject* self, PyObject *args)
PyObject* list = PyList_New(0);
+ ctree = pgf_lzr_wrap_linref(ctree, tmp_pool);
+
PgfBracketLznState state;
state.funcs = &pgf_bracket_lin_funcs;
state.stack = gu_new_buf(PyObject*, tmp_pool);
@@ -1499,18 +1501,8 @@ Concr_bracketedLinearize(ConcrObject* self, PyObject *args)
pgf_lzr_linearize(self->concr, ctree, 0, &state.funcs);
gu_pool_free(tmp_pool);
-
- PyObject* bracket = NULL;
- if (PyList_Size(list) == 1) {
- bracket = PyList_GetItem(list, 0);
- Py_INCREF(bracket);
- } else {
- PyErr_SetString(PGFError, "The abstract tree cannot be linearized");
- }
-
- Py_DECREF(list);
- return bracket;
+ return list;
}
static PyObject*