![]() |
for without next error - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: for without next error (/showthread.php?tid=1448) |
for without next error - maeloterkim - 10-10-2021 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" RE: for without next error - boriel - 10-11-2021 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. RE: for without next error - boriel - 10-12-2021 Ok, try this new beta, please, and tell me if it reports the error better: http://www.boriel.com/files/zxb/zxbasic-1.16.0-beta2.tar.gz http://www.boriel.com/files/zxb/zxbasic-1.16.0-beta2.zip http://www.boriel.com/files/zxb/zxbasic-1.16.0-beta2-win32.zip http://www.boriel.com/files/zxb/zxbasic-1.16.0-beta2-linux64.tar.gz http://www.boriel.com/files/zxb/zxbasic-1.16.0-beta2-macos.tar.gz RE: for without next error - maeloterkim - 10-12-2021 (10-12-2021, 03:52 PM)boriel Wrote: Ok, try this new beta, please, and tell me if it reports the error better: Yes ![]() now says for-sin-next.bas:5: error: FOR without NEXT |