djrieger / mjplusplus

A compiler for the MiniJava language
http://djrieger.github.io/mjplusplus/doc/doxygen/html/
6 stars 1 forks source link

Implement PositionAwareNode for all AST nodes referred to when reporting semantic errors #31

Closed djrieger closed 9 years ago

djrieger commented 9 years ago

All semantic errors should be recorded with a position. After implementing this functionality, the deprecated method SemanticAnalysis::void printError(std::string s) should be removed. It currently sets error positions to (1, 1).

djrieger commented 9 years ago

Got it wrong, SemanticAnalysis::void printError(std::string s) is still necessary, e.g. for reporting errors like "0 main methods defined" which do not have a position.

ratefuchs commented 9 years ago

Program-wide errors might use the program node as position (it is not optimal since Program has no own parts printed in toString but if we want to enforce it, we could do this). The best position for this error message would be the end of program (and for multiple mains there or at each additional main).