Re: buggy 4.0 program

new topic     » goto parent     » topic index » view thread      » older message » newer message
kinz said...
mattlewis said...
kinz said...

My question, why the error handling system can not separate the non-declared things and other things of the "referencing error" series?

Please define the difference between the two from the parser's perspective. The answer is that there isn't any. It can't know what you were thinking about, to know that you "meant to" declare something, or whether you just typed something incorrectly.

Non-declared exactly:
- the EOF is reached and
- there is no the declaration of the symbol in the whole program.
(The current parser's perspective is zero, so to say. It has nothing to do any more.)

But if it sees a different error (a syntax error of the missing operator type for example) then the parser stops. The parser stops. 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. 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.

I'm not sure if there is a difference between undeclared variables and unresolved forward references (that and conflicting references - variable declared twice - are the only reference errors that I know of).

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu