git @ Cat's Eye Technologies SixtyPical / 684b26d
locexpr() always returns a ForwardReference if it can't lookup it. Chris Pressey 3 years ago
1 changed file(s) with 14 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
356356 accum.append(self.locexpr())
357357 return accum
358358
359 def locexpr(self, forward=False):
359 def locexpr(self):
360360 if self.scanner.token in ('on', 'off', 'word') or self.scanner.token in self.context.consts or self.scanner.on_type('integer literal'):
361361 return self.const()
362 elif forward:
362 else:
363363 name = self.scanner.token
364364 self.scanner.scan()
365 return ForwardReference(name)
366 else:
367 loc = self.lookup(self.scanner.token)
368 self.scanner.scan()
369 return loc
370
371 def indlocexpr(self, forward=False):
365 loc = self.context.fetch(name)
366 if loc:
367 return loc
368 else:
369 return ForwardReference(name)
370
371 def indlocexpr(self):
372372 if self.scanner.consume('['):
373373 loc = self.locexpr()
374374 self.scanner.expect(']')
379379 loc = self.locexpr()
380380 return AddressRef(loc)
381381 else:
382 return self.indexed_locexpr(forward=forward)
383
384 def indexed_locexpr(self, forward=False):
385 loc = self.locexpr(forward=forward)
382 return self.indexed_locexpr()
383
384 def indexed_locexpr(self):
385 loc = self.locexpr()
386386 if not isinstance(loc, str):
387387 index = None
388388 if self.scanner.consume('+'):
482482 elif self.scanner.token in ("copy",):
483483 opcode = self.scanner.token
484484 self.scanner.scan()
485 src = self.indlocexpr(forward=True)
485 src = self.indlocexpr()
486486 self.scanner.expect(',')
487487 dest = self.indlocexpr()
488488 instr = SingleOp(self.scanner.line_number, opcode=opcode, dest=dest, src=src)