#ifndef _SERROR #define _SERROR /* * SError.h * * A class with only static members for formatting semantic errors * and for keeping track of whether any semantic errors occurred. * Only static members means you do not need to instantiate it, but rather * can use it via the scoping operator as shown below. * * Example use of member functions: * * SError::reportError(cerr, nodeWithError) * << "this is my error message" << endl; * * It uses nodeWithError to get the line number where the error occurred. * Returns the updated ostream, so you can string it together with * the error message using <<, as shown above. * * * bool stat = SError::hasErrors() * * Returns true iff reportError was ever called. * */ #include using namespace std; class TreeNode; class SError { private: static bool errorFlag; SError() { } // private so can't instantiate public: static ostream & reportError(ostream &o, TreeNode *t); static bool hasErrors() { return errorFlag; } }; #endif