* Add stack and queue properties to stateclass, for python access

This commit is contained in:
Matthew Honnibal 2015-08-08 23:32:42 +02:00
parent 3af938365f
commit 7bafc789e7
1 changed files with 8 additions and 0 deletions

View File

@ -36,6 +36,14 @@ cdef class StateClass:
self._buffer[i] = i self._buffer[i] = i
self._empty_token.lex = &EMPTY_LEXEME self._empty_token.lex = &EMPTY_LEXEME
@property
def stack(self):
return {self.S(i) for i in range(self._s_i)}
@property
def queue(self):
return {self.B(i) for i in range(self._b_i, self.length)}
cdef int E(self, int i) nogil: cdef int E(self, int i) nogil:
if self._e_i <= 0 or self._e_i >= self.length: if self._e_i <= 0 or self._e_i >= self.length:
return 0 return 0