Skip to content

Commit f838964

Browse files
committed
Fix error with multiline colon in ASM
zxbasm allows multiple instructions per line using colon (':'). The sequence ld e, a: ld e, 0 (for example) was not being parsed correctly. Fixed.
1 parent 23b28db commit f838964

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

asmlex.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,16 @@ def t_INITIAL_preproc_INTEGER(self, t):
245245

246246
def t_INITIAL_ID(self, t):
247247
r'[._a-zA-Z][._a-zA-Z0-9]*([ \t]*[:])?' # Any identifier
248-
249248
tmp = t.value # Saves original value
250249
if tmp[-1] == ':':
251-
t.type = 'LABEL'
252-
t.value = tmp[:-1].strip()
253-
return t
250+
c = self.find_column(t)
251+
if not self.input_data[t.lexpos - c + 1: t.lexpos].strip():
252+
t.type = 'LABEL'
253+
t.value = tmp[:-1].strip()
254+
return t
255+
256+
tmp = t.value = t.value[:-1].strip() # remove the colon ':'
257+
t.lexer.lexpos -= 1
254258

255259
t.value = tmp.upper() # Convert it to uppercase, since our internal tables uses uppercase
256260
id_ = tmp.lower()

tests/functional/asmcolon2.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ld e,a : ld d,0

tests/functional/asmcolon2.bin

3 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)