fix advancing in raw string when encountering a non-token during tokenisation

This commit is contained in:
Paul Gardner-Stephen committed 2019-04-26 22:09:16 +09:30
1 parent 1c46bc55e6
commit 428bd8e497
1 file changed
+22
+22
View File
@@ -24,9 +24,13 @@ tokenise_char:
;; Check if we have reached end of the line? ;; Check if we have reached end of the line?
lda $0110 lda $0110
tax
inc $0400,x
cmp $0113 cmp $0113
bne + bne +
inc $0428
;; Finished tokenising line ;; Finished tokenising line
;; Update tokenise_work1 and terminate with null ;; Update tokenise_work1 and terminate with null
ldx $0112 ldx $0112
@@ -36,6 +40,8 @@ tokenise_char:
rts rts
* *
;; More to do ;; More to do
inc $0429
;; Maximum keyword length ;; Maximum keyword length
lda #7 lda #7
@@ -46,34 +52,50 @@ tokenise_char_loop:
;; Returns packed length in tokenise_work2 and writes the packed ;; Returns packed length in tokenise_work2 and writes the packed
;; word at $0100+ ;; word at $0100+
inc $042a
;; Pack string ;; Pack string
ldx $0110 ldx $0110
lda $0111 lda $0111
sta tokenise_work1 sta tokenise_work1
sta $044f
jsr pack_word jsr pack_word
inc $042b
;; Search for it in keywords ;; Search for it in keywords
jsr keyword_search jsr keyword_search
php
inc $042c
plp
;; Did we find a keyword? ;; Did we find a keyword?
bcc found_token_in_line bcc found_token_in_line
inc $042d
;; Nope, so try shorter ;; Nope, so try shorter
dec $0111 dec $0111
bne tokenise_char_loop bne tokenise_char_loop
inc $042e
;; Is not a token, so copy to output verbatim ;; Is not a token, so copy to output verbatim
ldx $0110 ldx $0110
ldy $0112 ldy $0112
lda $0200,x lda $0200,x
sta $0200,y sta $0200,y
inc $0112 inc $0112
inc $0110
;; Tokenise next char ;; Tokenise next char
jmp tokenise_char jmp tokenise_char
found_token_in_line: found_token_in_line:
inc $042f
;; Got a token, so write it out ;; Got a token, so write it out
ldx $0112 ldx $0112
sta $0200,x sta $0200,x