Mercurial > lcfOS
comparison python/pyyacc.py @ 346:3bb7dcfe5529
expanded arm target
author | Windel Bouwman |
---|---|
date | Fri, 07 Mar 2014 17:05:32 +0100 |
parents | 4d204f6f7d4e |
children | 9667d78ba79e |
comparison
equal
deleted
inserted
replaced
345:b4882ff0ed06 | 346:3bb7dcfe5529 |
---|---|
286 def __init__(self, production, dotpos, look_ahead): | 286 def __init__(self, production, dotpos, look_ahead): |
287 self.production = production | 287 self.production = production |
288 self.dotpos = dotpos | 288 self.dotpos = dotpos |
289 assert self.dotpos <= len(self.production.symbols) | 289 assert self.dotpos <= len(self.production.symbols) |
290 self.look_ahead = look_ahead | 290 self.look_ahead = look_ahead |
291 self._is_shift = self.dotpos < len(self.production.symbols) | |
291 | 292 |
292 def getdata(self): | 293 def getdata(self): |
293 """ Gets the members as a tuple """ | 294 """ Gets the members as a tuple """ |
294 return (self.production, self.dotpos, self.look_ahead) | 295 return (self.production, self.dotpos, self.look_ahead) |
295 | 296 |
302 return self.getdata().__hash__() | 303 return self.getdata().__hash__() |
303 | 304 |
304 @property | 305 @property |
305 def IsReduce(self): | 306 def IsReduce(self): |
306 """ Check if this item has the dot at the end """ | 307 """ Check if this item has the dot at the end """ |
307 return self.dotpos == len(self.production.symbols) | 308 return not self._is_shift |
308 | 309 |
309 @property | 310 @property |
310 def IsShift(self): | 311 def IsShift(self): |
311 """ Check if this item is a shift item, i.e. the dot can proceed """ | 312 """ Check if this item is a shift item, i.e. the dot can proceed """ |
312 return self.dotpos < len(self.production.symbols) | 313 return self._is_shift |
313 | 314 |
314 @property | 315 @property |
315 def Next(self): | 316 def Next(self): |
316 """ Returns the symbol after the dot """ | 317 """ Returns the symbol after the dot """ |
317 return self.production.symbols[self.dotpos] | 318 return self.production.symbols[self.dotpos] |