hra1129 / msx_basic_compiler

MSX-BASICコンパイラ
MIT License
22 stars 2 forks source link

usage of two dimensional arrays randomly reported as syntax errors #21

Open zmajcenic opened 1 month ago

zmajcenic commented 1 month ago

Trying to compile a code like: 1560 SG(0,0)=6:SG(1,0)=0:SG(2,0)=0:SG(0,1)=7:SG(1,1)=0:SG(2,1)=0 1570 TG(0,0)=8:TG(1,0)=0:TG(2,0)=0:TG(0,1)=9:TG(1,1)=0:TG(2,1)=0 1580 BG(0,0)=10:BG(1,0)=0:BG(2,0)=0:BG(0,1)=11:BG(1,1)=0:BG(2,1)=0

reports syntax error on line 1570 but not on others

All arrays are DIMed the same at the start of program 10 DEFINT A-Z 20 DIM ZZ(13):DIM JR(2):DIM SA(3,31):DIM AD(14):DIM PG(2,1):DIM AR(1):DIM AL(1):DIM FG(2,1):DIM FR(1):DIM FL(1):DIM GG(2,1):DIM GR(1):DIM GL(1):DIM SG(2,1):DIM SR(1):DIM SL(1):DIM TG(2,1):DIM TR(1):DIM TL(1) 30 DIM BG(2,1):DIM BU(1):DIM CG(2,1):DIM CU(1):DIM PL(24,31):DIM CD(7,10)

This is example. Syntax errors thrown randomly in lines accessing two dimensional arrays.

hra1129 commented 1 month ago

When I tried it, there were no errors at compile time or at runtime.

Are the errors that appear randomly errors that occur at compile time? Or at runtime? What kind of errors do you get at runtime, for example?

In the case of a runtime error, it would be helpful if you could tell us the environment in which you ran the program. (MSX machine name, installed RAM capacity, number of disk drives) Maybe you are running out of memory and it is behaving suspiciously.

image

image

zmajcenic commented 4 weeks ago

I see a difference, I was compiling .BAS as in pre-compiled code. That gives me a syntax error. Compiling ASCII works well.

msx_bacon DEMO2USR.BAS DEMO2USR.ASM
MSX-BACON v0.0
=========================================================
Copyright (C)2023 t.hara
  Compile mode: MSX-BASIC Compatible.
  Optimization level: O2 (Code)
  Start address : 0x8010
  Stack size    : 256

Target: DEMO2USR.BAS (Precompiled code).
ERROR(220): Syntax error.
ERROR(220): Syntax error.
Found 2 error(s).

The same code in ASCII works well. Offending line is: 220 ZZ (0)=34:ZZ (1)=VARPTR (PT (0)):ZZ (2)=1:ZZ (3)=1:ZZ (4)=SB:ZZ (5)=32:ZZ (6)=24:ZZ (7)=0:ZZ (8)=0:ZZ (9)=32:ZZ (10)=24:I=USR (VARPTR (ZZ(0)))

hra1129 commented 4 weeks ago

I'm sorry. The MSX-BASIC intermediate language format is still incompletely supported. Please use the ASCII save method for the time being.

hra1129 commented 2 weeks ago

With the recent release, we now officially support reading intermediate code formats. Try it out and see if it does what you want it to do.

zmajcenic commented 1 week ago

Sadly it still does not work. This line reports syntax error 220 ZZ(0)=34:ZZ(1)=VARPTR(PT(0)):ZZ(2)=1:ZZ(3)=1:ZZ(4)=SB:ZZ(5)=32:ZZ(6)=24:ZZ(7)=0:ZZ(8)=0:ZZ(9)=32:ZZ(10)=24:I=USR(VARPTR(ZZ(0)))