Skip to content

Commit 71916bc

Browse files
authored
feat: allow for an optional variable reference in next (#121)
1 parent befdb16 commit 71916bc

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

source/common/commands/for.asm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,24 @@ _CITRNormal:
269269
;;
270270

271271
NextCommand: ;; [next]
272+
; Allow for an optional variable reference; no diagnostics for mismatched variable
273+
; references for now
274+
.cget ; look at first character
275+
cmp #KWC_EOL
276+
beq _NCForCheck
277+
278+
cmp #KWD_COLON
279+
beq _NCForCheck
280+
281+
cmp #$40 ; 40-7F => identifier reference
282+
bcc _NCSyntaxError ; some other token, syntax error
283+
cmp #$7F
284+
bcs _NCSyntaxError ; some other token, syntax error
285+
iny ; consume the identifier if it is there
286+
iny
287+
288+
_NCForCheck:
289+
; Check that we have a FOR loop on the stack
272290
lda #STK_FOR+11 ; check FOR is TOS
273291
ldx #ERRID_FOR ; this error
274292
jsr StackCheckFrame
@@ -344,4 +362,7 @@ _NCNoOverflow:
344362
_NCLoopBack:
345363
jmp STKLoadCodePosition ; loop back
346364

365+
_NCSyntaxError:
366+
jmp SyntaxError
367+
347368
.send code

0 commit comments

Comments
 (0)