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

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


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"
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.
Ok, try this new beta, please, and tell me if it reports the error better:
(10-12-2021, 03:52 PM)boriel Wrote: Ok, try this new beta, please, and tell me if it reports the error better:

Yes Smile  very good

now says

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

Forum Jump:

Users browsing this thread: 1 Guest(s)