gbdev / rgbds

Rednex Game Boy Development System - An assembly toolchain for the Nintendo Game Boy and Game Boy Color
https://rgbds.gbdev.io
MIT License
1.35k stars 172 forks source link

Any use of the RL keyword results in a syntax error #322

Closed Hawkbat closed 3 years ago

Hawkbat commented 5 years ago

Example:

ok rb 1
valid rw 1
invalid rl 1

Result:

ERROR: test.asm(3):
    syntax error
error: Assembly aborted in pass 1 (1 errors)!
ISSOtm commented 4 years ago

By the way, the reason why this occurs is because of a conflict in the grammar. (Yacc sees the rl and seems to require making a decision at this point, so it takes the instruction by default.)

aaaaaa123456789 commented 4 years ago

Considering there's no way any actual codebase has ever used this keyword (since it never worked), perhaps renaming it is the simplest solution?

ISSOtm commented 4 years ago

This is not the only conflict like this one, so I'd like to know if there's a way to resolve them (= tell yacc to look at more tokens to decide)

AntonioND commented 4 years ago

The problem is that... there is no way to do that. The instruction takes a number as argument, the keyword can also take a number as argument. It is always going to be ambiguous.

ISSOtm commented 4 years ago

The instruction takes a register as an argument, not a number.

pinobatch commented 4 years ago

And in case you're thinking what I'm thinking: 6502 has instructions amounting to sla [addr], srl [addr], rl [addr], rr [addr], inc [addr], and dec [addr]. Z80 and SM83 do not, and even if they did, there would be brackets.

AntonioND commented 4 years ago

The instruction takes a register as an argument, not a number.

Woops...

ISSOtm commented 3 years ago

Fixed by 57b734a.