Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for without next error
#1
Hi

I found that if i dont write a  next in a for the compiler only says "error: Unexpected end of file"

pointing to the LAST LINE  of the program

if i only have a few lines is "easy" to find the error

but if i have 2000 or more lines is a crazy thing to find the error

Can the compiler add a rule to search if every FOR have a NEXT and throw the error  "for without next" ?

This way is more easy to find the error in a BIG program with a lot of lines

You can look the example code



''EXAMPLE CODE WITH EXPLAINED ERROR

dim example as uByte = 0

for example = 0 to 10

    print example

'' THE NEXT MUST GO HERE IN LINE 9 but the compiler logically dont know that
'' BUT Can the compiler say  "error: for without next"
'' instead of "19: error: Unexpected end of file" ?
'' because if we have 2000 or more lines
'' and we dont know what happens
'' is a crazy thing search that error


print "end of program"
Reply
#2
That error is OK (somewhat).
The compiler is waiting to match the NEXT token, but it reached the end of the file and didn't found it.
If you add NEXT at the end of the line it would work.

But I could improve it by reporting the unclosed sentences. This is not as easy as it seems. I Will let you know of any improvements.
Reply
#3
Ok, try this new beta, please, and tell me if it reports the error better:
http://www.boriel.com/files/zxb/zxbasic-...ta2.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...-beta2.zip
http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz
Reply
#4
(10-12-2021, 03:52 PM)boriel Wrote: Ok, try this new beta, please, and tell me if it reports the error better:
http://www.boriel.com/files/zxb/zxbasic-...ta2.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...-beta2.zip
http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz


Yes Smile  very good

now says

for-sin-next.bas:5: error: FOR without NEXT
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)