#ifndef MESSAGES_H #define MESSAGES_H #include "types.h" #include "Symbol.h" #include /* Keeps track of and shows, warning and error messages */ class Messages { public: /* ctor */ Messages(); /* Show warnings messages */ void EnableWarnings(); /* Do not show warning message */ void DisableWarnings(); /* Give warning on line number lineno in source file */ void Warning(int lineno, const char *msg, ...); /* Give error on line number lineno in source file */ void Error(int lineno, const char *msg, ...); /* Give warning for a coercion */ void CoercionWarning(int lineno, ReturnType to, ReturnType from); /* Give error for using a function as a procedure */ void ReturnValueError(int lineno, const string& id, ReturnType type); /* Give error for a type mismatch */ void TypeError(int lineno, ReturnType expected, ReturnType received); /* Give error for undeclared identifier */ void UndeclaredIdError(int lineno, const std::string& id); /* Give error for an identifier that is declared multiple times */ void DeclaredIdError(int lineno, const std::string& id, int prev_lineno); /* Give error for identifier that is not a lvalue */ void LValueError(int lineno, const std::string& id); /* Give error for using an identifier that is not a rvalue */ void RValueError(int lineno, const std::string& id, SymbolType symbol_type); /* Give error for using id as function/procedure when it's not */ void CallError(int lineno, const std::string& id, SymbolType symbol_type); /* Give error for incorrect number of parameters in function/procedure call */ void ParamCountError(int lineno, int paramcount, Symbol *symbol); /* Show how many warnings and errors there were */ void ShowNumbers() const; /* Returns the number of errors */ int GetErrors() const; /* Returns the number of warnings */ int GetWarnings() const; private: std::string SignatureString(Symbol *symbol); bool show_warnings; int warnings; int suppressed; int errors; }; #endif /* MESSAGES_H */