summaryrefslogtreecommitdiff
path: root/python/src/sa/sym.pxi
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/sa/sym.pxi')
-rw-r--r--python/src/sa/sym.pxi16
1 files changed, 10 insertions, 6 deletions
diff --git a/python/src/sa/sym.pxi b/python/src/sa/sym.pxi
index 3fd6c5a7..4b41886f 100644
--- a/python/src/sa/sym.pxi
+++ b/python/src/sa/sym.pxi
@@ -53,14 +53,12 @@ cdef class Alphabet:
if self.isvar(sym):
if sym in self.id2sym:
return self.id2sym[sym]
-
ind = self.getindex(sym)
if ind > 0:
self.id2sym[sym] = "[%s,%d]" % (self.tocat(sym), ind)
else:
self.id2sym[sym] = "[%s]" % self.tocat(sym)
return self.id2sym[sym]
-
else:
return self.terminals.word(sym)
@@ -88,14 +86,20 @@ cdef class Alphabet:
cdef Alphabet ALPHABET = Alphabet()
-def sym_tostring(int sym):
+cdef char* sym_tostring(int sym):
return ALPHABET.tostring(sym)
-def sym_fromstring(bytes string, bint terminal):
- return ALPHABET.fromstring(string, terminal)
+cdef char* sym_tocat(int sym):
+ return ALPHABET.tocat(sym)
-def sym_isvar(int sym):
+cdef int sym_isvar(int sym):
return ALPHABET.isvar(sym)
+cdef int sym_getindex(int sym):
+ return ALPHABET.getindex(sym)
+
cdef int sym_setindex(int sym, int id):
return ALPHABET.setindex(sym, id)
+
+def sym_fromstring(bytes string, bint terminal):
+ return ALPHABET.fromstring(string, terminal)