Mercurial > lcfOS
comparison python/pyyacc.py @ 341:4d204f6f7d4e devel
Rewrite of assembler parts
author | Windel Bouwman |
---|---|
date | Fri, 28 Feb 2014 18:07:14 +0100 |
parents | c7cc54c0dfdf |
children | 3bb7dcfe5529 |
comparison
equal
deleted
inserted
replaced
340:c7cc54c0dfdf | 341:4d204f6f7d4e |
---|---|
264 return action_table, goto_table | 264 return action_table, goto_table |
265 | 265 |
266 | 266 |
267 class Production: | 267 class Production: |
268 """ Production rule for a grammar """ | 268 """ Production rule for a grammar """ |
269 def __init__(self, name, symbols, f=None): | 269 def __init__(self, name, symbols, f): |
270 self.name = name | 270 self.name = name |
271 self.symbols = symbols | 271 self.symbols = symbols |
272 self.f = f | 272 self.f = f |
273 | 273 |
274 def __repr__(self): | 274 def __repr__(self): |
307 return self.dotpos == len(self.production.symbols) | 307 return self.dotpos == len(self.production.symbols) |
308 | 308 |
309 @property | 309 @property |
310 def IsShift(self): | 310 def IsShift(self): |
311 """ Check if this item is a shift item, i.e. the dot can proceed """ | 311 """ Check if this item is a shift item, i.e. the dot can proceed """ |
312 return not self.IsReduce | 312 return self.dotpos < len(self.production.symbols) |
313 | 313 |
314 @property | 314 @property |
315 def Next(self): | 315 def Next(self): |
316 """ Returns the symbol after the dot """ | 316 """ Returns the symbol after the dot """ |
317 return self.production.symbols[self.dotpos] | 317 return self.production.symbols[self.dotpos] |