This is an AppleSoft issue where it puts spaces either side of a token.
PET/CBM BASIC (based off the same code base) doesn't do this.
Tokenising ignores spaces, this means it can be difficult on the PET to see some of the problems that the tokeniser can cause.
For example LET AFOR=ONER
gets parsed as LET A FOR = ON ER
Which is very difficult to see on a PET, I suspect someone at Apple changed this (IIRC the 8080 Basic is the same as a PET).
For the version I wrote in .Net I ended up only adding spaces on the left for Functions and both sides for Statements.
I seem to recall the Apple displays 10 PRINT SPC( 3)
which I thought was quite ugly and distinguishing for functions meant I could get 10 PRINT SPC(3)
which does look nicer.
So the original 6502 basic code from Microsoft (using the DEC cross assembler syntax) looks like this:
LDYI 255 ;LOOK AT RES'D WORD LIST.
RESRCH: DEX ;IS THIS THE RES'D WORD?
BEQ PRIT3 ;YES, GO TOSS IT UP..
RESCR1: INY
LDA RESLST,Y, ;END OF ENTRY?
BPL RESCR1 ;NO, CONTINUE PASSING.
BMI RESRCH
PRIT3: INY
LDA RESLST,Y
BMI PRIT4 ;END OF RESERVED WORD.
JSR OUTDO ;PRINT IT.
BNE PRIT3 ;END OF ENTRY? NO, TYPE REST
But the AppleSoft version looks like this (I've tidied up some of the labels so it's a better match):
LDY #$FF
RESRCH DEX ; SKIP KEYWORDS UNTIL REACH THIS ONE
BEQ PRIT3 ;
RESCR1 JSR GETCHR ; BUMP Y, GET CHAR FROM TABLE
BPL RESCR1 ; NOT AT END OF KEYWORD YET
BMI RESRCH ; END OF KEYWORD, ALWAYS BRANCHES
PRIT3 LDA #LOCHAR(' ') ; FOUND THE RIGHT KEYWORD
JSR OUTDO ; PRINT LEADING SPACE
L_LIST_4_4 JSR GETCHR ; PRINT THE KEYWORD
BMI L_LIST_4_5 ; LAST CHAR OF KEYWORD
JSR OUTDO ;
BNE L_LIST_4_4 ; ...ALWAYS
L_LIST_4_5 JSR OUTDO ; PRINT LAST CHAR OF KEYWORD
LDA #LOCHAR(' ') ; PRINT TRAILING SPACE
BNE LIST_1 ; ...ALWAYS, BACK TO ACTUAL LINE
As can clearly be seen there are an extra couple of spaces printed.
Also worth pointing out that mathematical operators like +-/* are tokens, I think <=
double separates so comes out as < =
. Finally there is some weirdness when things go beyond column 33 (I'd guess 80 column mode doesn't update MON_CH zero page so it doesn't trigger).