2015-06-08 23:39:54 +00:00
|
|
|
from libc.string cimport memcpy, memset
|
|
|
|
from libc.stdint cimport uint32_t
|
2015-06-09 19:20:14 +00:00
|
|
|
from ..vocab cimport EMPTY_LEXEME
|
2015-06-10 02:20:23 +00:00
|
|
|
from ..structs cimport Entity
|
2016-01-19 01:54:15 +00:00
|
|
|
from ..lexeme cimport Lexeme
|
|
|
|
from ..symbols cimport punct
|
|
|
|
from ..attrs cimport IS_SPACE
|
2015-06-08 23:39:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
cdef class StateClass:
|
2015-06-09 19:20:14 +00:00
|
|
|
def __init__(self, int length):
|
|
|
|
cdef Pool mem = Pool()
|
|
|
|
self.mem = mem
|
2016-02-01 01:22:21 +00:00
|
|
|
|
|
|
|
def __dealloc__(self):
|
|
|
|
del self.c
|
|
|
|
|
2015-08-08 21:32:42 +00:00
|
|
|
@property
|
|
|
|
def stack(self):
|
|
|
|
return {self.S(i) for i in range(self._s_i)}
|
|
|
|
|
|
|
|
@property
|
|
|
|
def queue(self):
|
2015-08-08 22:39:02 +00:00
|
|
|
return {self.B(i) for i in range(self._b_i)}
|
2015-08-08 21:32:42 +00:00
|
|
|
|
2015-06-09 23:35:28 +00:00
|
|
|
def print_state(self, words):
|
|
|
|
words = list(words) + ['_']
|
2015-06-10 08:13:03 +00:00
|
|
|
top = words[self.S(0)] + '_%d' % self.S_(0).head
|
|
|
|
second = words[self.S(1)] + '_%d' % self.S_(1).head
|
|
|
|
third = words[self.S(2)] + '_%d' % self.S_(2).head
|
2015-06-09 23:35:28 +00:00
|
|
|
n0 = words[self.B(0)]
|
|
|
|
n1 = words[self.B(1)]
|
2015-06-14 15:44:29 +00:00
|
|
|
return ' '.join((third, second, top, '|', n0, n1))
|