1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-10 06:30:41 +00:00

I lied. optimized lex scanner

This commit is contained in:
David Schmenk 2014-12-10 20:58:25 -08:00
parent 9b056aed69
commit a7dfaf1b53
2 changed files with 37 additions and 19 deletions

Binary file not shown.

View File

@ -1,3 +1,4 @@
//
// Global constants
//
@ -626,13 +627,6 @@ asm cout
JSR $FDED
BIT LCRDEN+LCBNK2
RTS
TOUPR AND #$7F
CMP #'a'
BCC +
CMP #'z'+1
BCS +
SBC #$1F
+ RTS
end
//
// CHAR IN
@ -720,12 +714,11 @@ end
//end
asm toupper
LDA ESTKL,X
AND #$7F
CMP #'a'
BCC +
TOUPR AND #$7F
CMP #'z'+1
BCS +
SEC
CMP #'a'
BCC +
SBC #$20
+ STA ESTKL,X
RTS
@ -792,6 +785,31 @@ CPLNLP LDA (SRC),Y
++ STA (DST),Y
RTS
end
//
//def skipspace(scanptr)
// while ^scanptr == ' '
// scanptr = scanptr + 1
// loop
// return scanptr
//end
asm skipspace(scanptr)
LDA #$00
STA SRCL
LDA ESTKH,X
STA SRCH
LDY ESTKL,X
- LDA (SRC),Y
CMP #' '
BNE +
INY
BNE -
INC SRCH
BNE -
+ STY ESTKL,X
LDA SRCH
STA ESTKH,X
RTS
end
//def isalpha(c)
// if c >= 'A' and c <= 'Z'
// return TRUE
@ -2627,19 +2645,13 @@ def scan
//
// Skip whitespace
//
while ^scanptr == ' '
scanptr = scanptr + 1
loop
scanptr = skipspace(scanptr)
tknptr = scanptr
scanchr = ^scanptr
//
// Scan for token based on first character
//
if !scanchr or scanchr == ';'
if token <> EOF_TKN
token = EOL_TKN
fin
elsif isalpha(scanchr)
if isalpha(scanchr)
//
// ID, either variable name or reserved word
//
@ -2782,6 +2794,12 @@ def scan
fin
scanptr = scanptr + 1
break
is 0
is ';'
if token <> EOF_TKN
token = EOL_TKN
fin
break
otherwise
//
// Simple single character tokens