simonowen / pyz80

pyz80 - a Z80 cross assembler
GNU General Public License v2.0
18 stars 8 forks source link

@abc not handled correctly #21

Closed stefandrissen closed 3 years ago

stefandrissen commented 3 years ago

I forgot to terminate a local label with a colon. Prior to #20 for dec,(hl) the incomplete label:

@abc

Would result in:

        [exec] pass  1 ...
        [exec] src\view.s:1 error: OpCode not recognised
        [exec]   @abc

Now it results in another scary untraceable error:

        [exec] Traceback (most recent call last):
        [exec]   File "C:\Users\stefan\git\pyz80\pyz80.py", line 1962, in <module>
        [exec] pass  1 ...
        [exec]     assembler_pass(p, inputfile)
        [exec]   File "C:\Users\stefan\git\pyz80\pyz80.py", line 1764, in assembler_pass
        [exec]     bytes = assemble_instruction(p,opcode)
        [exec]   File "C:\Users\stefan\git\pyz80\pyz80.py", line 1652, in assemble_instruction
        [exec]     opcodeargs = re.match('^(\w+)(.*)', line).groups()
        [exec] AttributeError: 'NoneType' object has no attribute 'groups'

Global labels do not have this issue.

simonowen commented 3 years ago

Dang, forgot about @ as a valid character in that position. I'll re-open the original bug as the fix has caused this.

simonowen commented 3 years ago

This type of syntax error now shows a new message:

pass  1 ...
test.asm:1 error: Expected opcode or directive
         @abc

Thanks for the report!