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