source: liacs/coco/assignment2/messages.h@ 257

Last change on this file since 257 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 2.1 KB
Line 
1#ifndef MESSAGES_H
2#define MESSAGES_H
3
4#include "types.h"
5#include "Symbol.h"
6#include <string>
7
8/* Keeps track of and shows, warning and error messages */
9class Messages {
10public:
11 /* ctor */
12 Messages();
13
14 /* Show warnings messages */
15 void EnableWarnings();
16 /* Do not show warning message */
17 void DisableWarnings();
18
19 /* Give warning on line number lineno in source file */
20 void Warning(int lineno, const char *msg, ...);
21 /* Give error on line number lineno in source file */
22 void Error(int lineno, const char *msg, ...);
23
24 /* Give warning for a coercion */
25 void CoercionWarning(int lineno, ReturnType to, ReturnType from);
26
27 /* Give error for using a function as a procedure */
28 void ReturnValueError(int lineno, const string& id, ReturnType type);
29
30 /* Give error for a type mismatch */
31 void TypeError(int lineno, ReturnType expected, ReturnType received);
32
33 /* Give error for undeclared identifier */
34 void UndeclaredIdError(int lineno, const std::string& id);
35
36 /* Give error for an identifier that is declared multiple times */
37 void DeclaredIdError(int lineno, const std::string& id, int prev_lineno);
38
39 /* Give error for identifier that is not a lvalue */
40 void LValueError(int lineno, const std::string& id);
41
42 /* Give error for using an identifier that is not a rvalue */
43 void RValueError(int lineno, const std::string& id, SymbolType symbol_type);
44
45 /* Give error for using id as function/procedure when it's not */
46 void CallError(int lineno, const std::string& id, SymbolType symbol_type);
47
48 /* Give error for incorrect number of parameters in function/procedure call */
49 void ParamCountError(int lineno, int paramcount, Symbol *symbol);
50
51 /* Show how many warnings and errors there were */
52 void ShowNumbers() const;
53
54 /* Returns the number of errors */
55 int GetErrors() const;
56
57 /* Returns the number of warnings */
58 int GetWarnings() const;
59private:
60 std::string SignatureString(Symbol *symbol);
61 bool show_warnings;
62 int warnings;
63 int suppressed;
64 int errors;
65};
66
67#endif /* MESSAGES_H */
Note: See TracBrowser for help on using the repository browser.