Re: buggy 4.0 program
- Posted by mattlewis (admin) Dec 15, 2008
- 1560 views
It does not continue to parse the rest of the program to see if the symbol is ever declared or not, so at the point where the syntax error is reported, it is too soon for the parser to know about undeclared variables/unresolved forward references.
Ok, I know now that it does not continue to parse the rest of the program. And my question is why? Why it can not collect the different errors in same manner as "referencing error" series?
The only way to fix this (without getting rid of forward referencing altogether) is to add an extra pass to the parser, with the variable reference resolving occuring on the first pass and the syntax error check on the second pass.
Why not to collect all at all errors to EOF and then generate complete error message after single pass?
These more 'serious' errors put the parser into an undefined state. For instance, when it though you were creating an expression, but it found a procedure, did you type the name incorrectly? Did you miss something else? Should that have simply not been there (i.e., you forgot to comment it out or delete it)? At this point, it's not clear where the next statement should begin. It might have therefore missed something very important to parsing your program (a missing end marker?) that causes the rest of the program to be unparseable, resulting in a torrent of errors (as Derek mentioned). In these cases, when the syntax cannot possibly be correct, it's better to stop the parser and report the error.
Matt