mirror of
https://github.com/mnaberez/py65.git
synced 2025-01-17 10:30:19 +00:00
Handle all syntax errors in immediate values
This commit is contained in:
parent
23bd9b9a39
commit
2dde6bdafe
@ -101,15 +101,15 @@ class Assembler:
|
|||||||
|
|
||||||
# target is an immediate value
|
# target is an immediate value
|
||||||
if target.startswith('#'):
|
if target.startswith('#'):
|
||||||
if target[1] in ("'", '"'): # quoted ascii character
|
try:
|
||||||
try:
|
if target[1] in ("'", '"'): # quoted ascii character
|
||||||
number = ord(target[2])
|
number = ord(target[2])
|
||||||
except IndexError:
|
else:
|
||||||
raise SyntaxError(statement)
|
number = self._address_parser.number(target[1:])
|
||||||
else:
|
except IndexError:
|
||||||
number = self._address_parser.number(target[1:])
|
raise SyntaxError(statement)
|
||||||
|
|
||||||
if (number < 0x00) or (number > self._mpu.byteMask):
|
if (number < 0) or (number > self._mpu.byteMask):
|
||||||
raise OverflowError
|
raise OverflowError
|
||||||
statement = before + '#$' + self._mpu.BYTE_FORMAT % number
|
statement = before + '#$' + self._mpu.BYTE_FORMAT % number
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ class AssemblerTests(unittest.TestCase):
|
|||||||
def test_assemble_bad_syntax_raises_syntaxerror(self):
|
def test_assemble_bad_syntax_raises_syntaxerror(self):
|
||||||
self.assertRaises(SyntaxError,
|
self.assertRaises(SyntaxError,
|
||||||
self.assemble, 'foo')
|
self.assemble, 'foo')
|
||||||
|
self.assertRaises(SyntaxError,
|
||||||
|
self.assemble, 'lda #')
|
||||||
self.assertRaises(SyntaxError,
|
self.assertRaises(SyntaxError,
|
||||||
self.assemble, 'lda #"')
|
self.assemble, 'lda #"')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user