Skip to content

Commit 477fa8b

Browse files
Parser: allow leading spaces
1 parent 44c4bd2 commit 477fa8b

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

intbasic.system.s

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -565,25 +565,27 @@ zp_stash:
565565
.endproc ; CommandHook
566566

567567
.proc ExecBuffer
568-
ldx #0
568+
ldx #0 ; X = offset in cmdtable
569569
stx cmdnum
570-
dex ; -1; immediately incremented to 0
571570

572571
;; Check command
573-
loop: ldy #$FF ; -1, immediately incremented to 0
574-
: iny
575-
inx
576-
lda cmdtable,x
572+
loop: ldy #0 ; Y = offset in buffer
573+
jsr SkipSpaces
574+
: lda cmdtable,x
577575
beq dispatch
578576
cmp intbasic::IN,y
579-
beq :- ; next character
577+
bne next
578+
inx
579+
iny
580+
bne :- ; always
580581

581582
;; Next command
582-
next: inx
583-
lda cmdtable,x
584-
bne next
583+
: inx
584+
next: lda cmdtable,x
585+
bne :-
585586
inc cmdnum
586-
lda cmdtable+1,x
587+
inx
588+
lda cmdtable,x
587589
bne loop
588590

589591
;; No match
@@ -780,7 +782,7 @@ done: stx PATHBUF
780782
;;; ============================================================
781783
;;; Skip over spaces in input buffer
782784
;;; Input: Y = current position
783-
;;; Output: Y = new position, A = char at new position
785+
;;; Output: Y = new position, A = char at new position, X unchanged
784786

785787
.proc SkipSpaces
786788
: lda intbasic::IN,y

res/TESTS.INT

69 Bytes
Binary file not shown.

res/tests.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ NEW
6868
343 PRINT D$;"BSAVE BIN,V254,A8192,L1"
6969
344 A=1 : GOSUB 10000
7070

71+
350 TEST$ = "Leading spaves"
72+
351 PRINT D$;" BSAVE BIN,A8192,L1"
73+
352 A=1 : GOSUB 10000
74+
7175
400 REM ******************************
7276
401 SEC$ = "Commands"
7377
402 REM ******************************

0 commit comments

Comments
 (0)