Boriel Basic Forum
"Illegal Preprocessor" errors on some files (*solved*) - Printable Version

+- Boriel Basic Forum (https://forum.boriel.com)
+-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://forum.boriel.com/forumdisplay.php?fid=15)
+---- Thread: "Illegal Preprocessor" errors on some files (*solved*) (/showthread.php?tid=325)



"Illegal Preprocessor" errors on some files (*solved*) - LTee - 2011-03-07

For the 1.2.8 test I recompiled all the sources I have kicking around and discovered that a couple won't compile any more. Specifically these are ones containing ASM sections with comments, and they throw an "illegal preprocessor character" error. Curiously the line numbers of the errors don't seem to help much, they seem to point to lines which are blank or ones which don't actually have the character that the preprocessor is complaining about.

This isn't a regression in 1.2.8, by the way - I checked them with 1.2.7 as well and the same problem happens there. Guess I didn't recompile my entire collection of source for a while. :-)

I've included one of the files in full, because I didn't write them so I'm not sure how to cut them down. Apologies. If you need the other one as well then let me know.

Code:
SUB dieSound() DIM n as uByte FOR n=1 to 2 BEEP rnd/600,9 BEEP rnd/100,(-14-(rnd*5)) PAUSE 1 NEXT n END SUB SUB putChars(x as uByte,y as uByte, dataAddress as uInteger) asm BLPutChar: LD a,(IX+5) ld l,a ld a,(IX+7) LD b,a ; save it AND 24 add a,64 ; 256 byte "page" for screen - 256*64=16384. Change this if you are working with a screen address elsewhere, such as a buffer. ld h,a ld a,b ; y value AND 7 rrca rrca rrca OR l ld l,a EX DE,HL PUSH DE ; save our address LD L,(IX+8) ; data address LD H,(IX+9) EX AF,AF' LD A,4 ;row counter EX AF,AF' BLPutCharLoop: LD B,8 BLPutCharOneCharLoop: XOR A; LD A,0 LD C,A ; gets screen address in DE, and bytes address in HL. Copies the row to the screen LDI ; also decrements B. LDI LDI LDI ; 4 bytes copied. LD A,C ADD A,E ;(A should be -4) LD E,A INC D LD A,B OR A JP NZ,BLPutCharOneCharLoop EX AF,AF' DEC A JR Z, BLPutCharsEnd ; We've done all 4 rows. EX AF,AF' ;need to sort our screen address for the next row. Is it right? LD A,E ; DE has screen address ADD A,32 ; down to next character LD E,A JR C, BLPutCharsCont ; Not in next third. LD A,D SUB 8 LD D,A BLPutCharsCont: JP BLPutCharLoop BLPutCharsEnd: end asm END SUB SUB graphicsData() RETURN dice: ASM ; Name : Dice ; Frame : 0 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Dice000: asm ; pixels and mask bit pairs defb 1, 83, 48, 0 defb 3, 83, 14, 0 defb 6, 200, 67, 0 defb 4, 200, 97, 128 defb 12, 136, 96, 96 defb 8, 4, 32, 24 defb 24, 4, 8, 4 defb 16, 4, 140, 4 defb 16, 2, 14, 4 defb 32, 7, 3, 0 defb 64, 12, 64, 2 defb 64, 8, 96, 2 defb 128, 24, 24, 2 defb 128, 18, 6, 96 defb 0, 51, 1, 249 defb 128, 35, 192, 241 defb 128, 67, 128, 57 defb 64, 192, 0, 12 defb 0, 128, 0, 7 defb 68, 158, 0, 33 defb 71, 30, 0, 241 defb 47, 30, 0, 113 defb 14, 8, 0, 243 defb 44, 0, 0, 2 defb 52, 240, 1, 4 defb 24, 240, 7, 136 defb 24, 240, 7, 136 defb 8, 64, 7, 144 defb 6, 0, 0, 0 defb 3, 0, 0, 32 defb 0, 192, 28, 64 defb 0, 112, 60, 64 ; Name : Dice ; Frame : 1 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Dice001: asm ; pixels and mask bit pairs defb 0, 28, 194, 128 defb 0, 49, 194, 128 defb 0, 193, 19, 64 defb 1, 128, 19, 32 defb 14, 0, 5, 32 defb 57, 0, 4, 16 defb 71, 16, 40, 24 defb 183, 48, 32, 8 defb 44, 115, 16, 12 defb 0, 199, 240, 4 defb 0, 15, 48, 130 defb 64, 6, 17, 195 defb 64, 56, 24, 193 defb 4, 225, 72, 193 defb 25, 129, 204, 64 defb 191, 3, 196, 1 defb 188, 33, 194, 1 defb 48, 120, 2, 2 defb 224, 120, 1, 64 defb 132, 120, 1, 98 defb 143, 0, 0, 226 defb 142, 0, 0, 228 defb 207, 0, 0, 96 defb 64, 0, 0, 36 defb 32, 0, 15, 44 defb 48, 0, 15, 24 defb 16, 0, 15, 24 defb 8, 1, 226, 24 defb 8, 1, 224, 120 defb 4, 1, 224, 224 defb 2, 56, 67, 128 defb 2, 60, 12, 0 ; Name : Dice ; Frame : 2 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Dice002: asm ; pixels and mask bit pairs defb 255, 255, 252, 0 defb 192, 0, 2, 0 defb 167, 128, 121, 0 defb 147, 192, 60, 128 defb 136, 0, 0, 64 defb 164, 3, 192, 32 defb 178, 1, 224, 16 defb 177, 0, 0, 8 defb 176, 158, 3, 196 defb 144, 79, 1, 226 defb 128, 63, 255, 255 defb 128, 160, 0, 1 defb 128, 224, 0, 1 defb 128, 227, 12, 49 defb 128, 231, 158, 121 defb 128, 103, 158, 121 defb 128, 35, 12, 49 defb 160, 32, 0, 1 defb 176, 32, 0, 1 defb 176, 32, 0, 1 defb 176, 32, 0, 1 defb 144, 32, 0, 1 defb 64, 32, 0, 1 defb 32, 160, 0, 1 defb 16, 224, 0, 1 defb 8, 227, 12, 49 defb 4, 231, 158, 121 defb 2, 103, 158, 121 defb 1, 35, 12, 49 defb 0, 160, 0, 1 defb 0, 96, 0, 1 defb 0, 63, 255, 255 ; Name : Dice ; Frame : 3 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Dice003: asm ; pixels and mask bit pairs defb 0, 1, 184, 0 defb 0, 26, 14, 0 defb 1, 160, 243, 128 defb 15, 0, 121, 192 defb 30, 224, 16, 112 defb 17, 248, 0, 28 defb 48, 112, 120, 6 defb 32, 52, 60, 131 defb 71, 14, 8, 28 defb 207, 3, 128, 15 defb 135, 0, 220, 0 defb 135, 56, 126, 0 defb 0, 120, 28, 12 defb 0, 56, 6, 192 defb 0, 57, 226, 11 defb 0, 1, 194, 115 defb 0, 1, 230, 22 defb 0, 0, 140, 0 defb 128, 0, 12, 1 defb 192, 0, 16, 1 defb 192, 0, 17, 195 defb 206, 0, 33, 130 defb 14, 0, 35, 4 defb 15, 0, 66, 12 defb 14, 112, 192, 8 defb 192, 112, 224, 24 defb 32, 121, 224, 16 defb 8, 113, 192, 48 defb 6, 3, 64, 160 defb 1, 6, 1, 160 defb 0, 196, 24, 0 defb 0, 125, 128, 0 ; Name : Dice ; Frame : 4 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Dice004: asm ; pixels and mask bit pairs defb 0, 125, 128, 96 defb 1, 196, 24, 32 defb 3, 7, 129, 160 defb 6, 3, 192, 176 defb 24, 113, 193, 48 defb 32, 121, 161, 216 defb 192, 112, 128, 216 defb 0, 80, 192, 232 defb 0, 0, 98, 12 defb 0, 14, 35, 4 defb 192, 15, 49, 130 defb 192, 14, 17, 195 defb 192, 14, 20, 1 defb 128, 0, 14, 1 defb 0, 0, 143, 0 defb 56, 1, 231, 6 defb 56, 1, 194, 3 defb 120, 1, 226, 3 defb 56, 0, 6, 192 defb 0, 0, 28, 40 defb 135, 0, 112, 24 defb 135, 0, 192, 4 defb 207, 3, 0, 15 defb 71, 12, 8, 28 defb 96, 48, 60, 3 defb 48, 124, 120, 6 defb 49, 248, 0, 28 defb 14, 0, 0, 112 defb 15, 0, 1, 192 defb 1, 160, 3, 128 defb 0, 26, 14, 0 defb 0, 1, 184, 0 ; Name : Die1 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Die1: asm ; pixels and mask bit pairs defb 255, 255, 252, 0 defb 192, 0, 2, 0 defb 160, 0, 1, 0 defb 144, 0, 0, 128 defb 136, 0, 0, 64 defb 164, 3, 192, 32 defb 178, 1, 224, 16 defb 177, 0, 0, 8 defb 176, 128, 0, 4 defb 144, 64, 0, 2 defb 128, 63, 255, 255 defb 128, 32, 0, 1 defb 128, 32, 0, 1 defb 128, 35, 0, 49 defb 132, 39, 128, 121 defb 134, 39, 128, 121 defb 134, 35, 0, 49 defb 134, 32, 0, 1 defb 130, 32, 0, 1 defb 128, 32, 12, 1 defb 128, 32, 30, 1 defb 128, 32, 30, 1 defb 64, 32, 12, 1 defb 32, 160, 0, 1 defb 16, 224, 0, 1 defb 8, 227, 0, 49 defb 4, 231, 128, 121 defb 2, 103, 128, 121 defb 1, 35, 0, 49 defb 0, 160, 0, 1 defb 0, 96, 0, 1 defb 0, 63, 255, 255 ; Name : Die2 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Die2: asm ; pixels and mask bit pairs defb 255, 255, 252, 0 defb 192, 0, 2, 0 defb 167, 128, 1, 0 defb 147, 192, 0, 128 defb 136, 0, 0, 64 defb 164, 0, 0, 32 defb 178, 0, 0, 16 defb 177, 0, 0, 8 defb 176, 128, 3, 196 defb 144, 64, 1, 226 defb 128, 63, 255, 255 defb 160, 160, 0, 1 defb 176, 224, 0, 1 defb 176, 227, 0, 49 defb 176, 231, 128, 121 defb 144, 103, 128, 121 defb 128, 35, 0, 49 defb 160, 160, 0, 1 defb 176, 224, 0, 1 defb 176, 224, 0, 1 defb 176, 224, 0, 1 defb 144, 96, 0, 1 defb 64, 32, 0, 1 defb 32, 160, 0, 1 defb 16, 224, 0, 1 defb 8, 227, 0, 49 defb 4, 231, 128, 121 defb 2, 103, 128, 121 defb 1, 35, 0, 49 defb 0, 160, 0, 1 defb 0, 96, 0, 1 defb 0, 63, 255, 255 ; Name : Die3 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Die3: asm ; pixels and mask bit pairs defb 255, 255, 252, 0 defb 192, 0, 2, 0 defb 167, 128, 1, 0 defb 147, 192, 0, 128 defb 136, 0, 0, 64 defb 164, 3, 192, 32 defb 178, 1, 224, 16 defb 177, 0, 0, 8 defb 176, 128, 1, 228 defb 144, 64, 0, 242 defb 128, 63, 255, 255 defb 128, 160, 0, 1 defb 128, 224, 0, 1 defb 128, 224, 0, 1 defb 132, 224, 0, 1 defb 134, 96, 0, 1 defb 134, 32, 0, 1 defb 166, 32, 0, 1 defb 178, 32, 0, 1 defb 176, 32, 12, 1 defb 176, 32, 30, 1 defb 144, 32, 30, 1 defb 64, 32, 12, 1 defb 32, 160, 0, 1 defb 16, 224, 0, 1 defb 8, 224, 0, 1 defb 4, 224, 0, 1 defb 2, 96, 0, 1 defb 1, 32, 0, 1 defb 0, 160, 0, 1 defb 0, 96, 0, 1 defb 0, 63, 255, 255 ; Name : Die4 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Die4: asm ; pixels and mask bit pairs defb 255, 255, 252, 0 defb 192, 0, 2, 0 defb 167, 128, 121, 0 defb 147, 192, 60, 128 defb 136, 0, 0, 64 defb 164, 0, 0, 32 defb 178, 0, 0, 16 defb 177, 0, 0, 8 defb 176, 158, 3, 196 defb 144, 79, 1, 226 defb 128, 63, 255, 255 defb 160, 160, 0, 1 defb 176, 224, 0, 1 defb 176, 227, 0, 1 defb 176, 231, 128, 1 defb 144, 103, 128, 1 defb 128, 35, 0, 1 defb 160, 160, 0, 1 defb 176, 224, 0, 1 defb 176, 224, 0, 1 defb 176, 224, 0, 1 defb 144, 96, 0, 1 defb 64, 32, 0, 1 defb 32, 160, 0, 1 defb 16, 224, 0, 1 defb 8, 224, 0, 49 defb 4, 224, 0, 121 defb 2, 96, 0, 121 defb 1, 32, 0, 49 defb 0, 160, 0, 1 defb 0, 96, 0, 1 defb 0, 63, 255, 255 ; Name : Die5 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Die5: asm ; pixels and mask bit pairs defb 255, 255, 252, 0 defb 192, 0, 2, 0 defb 167, 128, 121, 0 defb 147, 192, 60, 128 defb 136, 0, 0, 64 defb 132, 3, 192, 32 defb 130, 1, 224, 16 defb 129, 0, 0, 8 defb 128, 158, 3, 196 defb 128, 79, 1, 226 defb 128, 63, 255, 255 defb 128, 32, 0, 1 defb 128, 32, 0, 1 defb 128, 35, 0, 1 defb 132, 39, 128, 1 defb 134, 39, 128, 1 defb 134, 35, 0, 1 defb 134, 32, 0, 1 defb 130, 32, 0, 1 defb 128, 32, 12, 1 defb 128, 32, 30, 1 defb 128, 32, 30, 1 defb 64, 32, 12, 1 defb 32, 32, 0, 1 defb 16, 32, 0, 1 defb 8, 32, 0, 49 defb 4, 32, 0, 121 defb 2, 32, 0, 121 defb 1, 32, 0, 49 defb 0, 160, 0, 1 defb 0, 96, 0, 1 defb 0, 63, 255, 255 ; Name : Die6 ; Size : 32x32 ; Palette: ZX Spectrum ; Masked : No ; RowOrder: Classic end asm Die6: asm ; pixels and mask bit pairs defb 255, 255, 252, 0 defb 192, 0, 2, 0 defb 167, 128, 121, 0 defb 147, 192, 60, 128 defb 136, 0, 0, 64 defb 164, 240, 15, 32 defb 178, 120, 7, 144 defb 177, 0, 0, 8 defb 176, 158, 3, 196 defb 144, 79, 1, 226 defb 128, 63, 255, 255 defb 128, 160, 0, 1 defb 128, 224, 0, 1 defb 128, 227, 0, 49 defb 128, 231, 128, 121 defb 128, 103, 128, 121 defb 128, 35, 0, 49 defb 160, 32, 0, 1 defb 176, 32, 0, 1 defb 176, 32, 12, 1 defb 176, 32, 30, 1 defb 144, 32, 30, 1 defb 64, 32, 12, 1 defb 32, 160, 0, 1 defb 16, 224, 0, 1 defb 8, 227, 0, 49 defb 4, 231, 128, 121 defb 2, 103, 128, 121 defb 1, 35, 0, 49 defb 0, 160, 0, 1 defb 0, 96, 0, 1 defb 0, 63, 255, 255 end asm blank: asm blank: defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 defb 0, 0, 0, 0 END ASM END SUB REM Initialize Everything graphicsData() DIM diceFrames(3) AS uInteger diceFrames(0)=@Dice000 diceFrames(1)=@Dice001 diceFrames(2)=@Dice002 diceFrames(3)=@Dice003 DIM diceSprites(5) AS uInteger diceSprites(0)=@Die1 diceSprites(1)=@Die2 diceSprites(2)=@Die3 diceSprites(3)=@Die4 diceSprites(4)=@Die5 diceSprites(5)=@Die6 FUNCTION rollDice(x as uByte, y as uByte) as uByte DIM roll,frames,i as uByte roll = INT(RND*6) : REM Rolls 0-5 for animation. frames=INT(rnd*6)+4 FOR i=1 to frames dieSound() asm HALT end asm IF(x+i)<>0 then putChars(x+i-1,y,@blank) : END IF IF i MOD 5 =0 then putChars(x+i,y,diceSprites(rnd*6)) ELSE putChars(x+i,y,diceFrames((i mod 5)-1)) END IF NEXT i PAUSE 1 putChars(x+i-1,y,@blank) putChars(x+i,y,diceSprites(roll)) return roll+1 END FUNCTION print rollDice(0,0) print rollDice(15,0)

On a possibly-related note, I've discovered that Print42.bas no longer compiles in 1.2.7/1.2.8. That gives the following error:
Code:
Print42.bas:390: Error: Syntax error. Unexpected token 'DEFB' [DEFB]



Re: "Illegal Preprocessor" errors on some files containing A - boriel - 2011-03-08

Hmm. This seems to be another bug in the new preprocessor. Now fixed. Download v 1.2.8r2127 and check it. Should be fixed now. Also please, check it against PRINT42 should work ok too.


Re: "Illegal Preprocessor" errors on some files containing A - LTee - 2011-03-08

Thanks, boriel!

That seems to have fixed the problems with most of my test files, apart from the ones which reference Print42.bas (or Print64.bas, now that I check it). Those are still throwing 'unexpected token' errors, as before.


Re: "Illegal Preprocessor" errors on some files containing A - boriel - 2011-03-08

These are bugs in the preprocessor with PRINT64 code :!: Confusedhock:
There are chars \ and _ which join the next line so it reads
DEFB xx DEFB yy
which throws the syntax error.
The ZXbpp is not filtering comments. Let me fix them...


Re: "Illegal Preprocessor" errors on some files containing A - boriel - 2011-03-09

Please download 1.2.8r2139 here and tell me if it works now (it does for me) :roll:


Re: "Illegal Preprocessor" errors on some files containing A - LTee - 2011-03-09

Well, good news... and bad news. I always seem to bring some bad news, sorry. :-)

The new version will now compile Print42.bas and Print64.bas. However, I'm still having problems compiling programs which USE those files.

For example, this very simple test program:
Code:
#include <print42.bas> CLS printat42(0,0) print42("Testing the 42-character print routines.") printat42(1,0) print42("Might be nice to use for the credits page.")

When trying to compile this I get the following error:
Code:
Print42Test.bas:23: Error: Undefined label '__LOADSTR'



Re: "Illegal Preprocessor" errors on some files containing A - boriel - 2011-03-09

LTee Wrote:Well, good news... and bad news. I always seem to bring some bad news, sorry. :-)

The new version will now compile Print42.bas and Print64.bas. However, I'm still having problems compiling programs which USE those files.

For example, this very simple test program:
Code:
#include <print42.bas> CLS printat42(0,0) print42("Testing the 42-character print routines.") printat42(1,0) print42("Might be nice to use for the credits page.")

When trying to compile this I get the following error:
Code:
Print42Test.bas:23: Error: Undefined label '__LOADSTR'

This error should happen only in 1.2.8 (code rearrangement). Thanks for the report Smile
Unfortunately, I find a bit hard to fix 1.2.7 and generate a new .msi :oops: but I guess it's needed in order to release an stable version for other users... :?:


Re: "Illegal Preprocessor" errors on some files containing A - LTee - 2011-03-09

I probably should've picked this up earlier, apologies - I must not have recompiled my entire set of routines during the 1.2.7 beta period for some reason.

Did you have any ideas on the problem I was having with declare, by the way? I'm still having no luck getting my code to compile. :-(
https://forum.boriel.com/help-support/returning-a-string-from-a-function-t599.html


Re: "Illegal Preprocessor" errors on some files containing A - boriel - 2011-03-09

Download here version 1.2.8r2151
Seems to be fixed now. :oops: Let me check the other post...


Re: "Illegal Preprocessor" errors on some files containing A - LTee - 2011-03-10

Checked and confirmed fixed in 2153 - thanks! Big Grin