-
Notifications
You must be signed in to change notification settings - Fork 0
/
Admin.h
79 lines (68 loc) · 1.95 KB
/
Admin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef Admin_H
#define Admin_H
#include <fstream>
#include <ostream>
#include <vector>
#include "ASTNode.h"
#include "SemanticAnalyzer.h"
#include "QuadrupleGenerator.h"
class Scanner;
class Parser;
class Token;
#define PARSER_ENTER 0
#define PARSER_EXIT 1
#define PARSER_MATCH 0
#define PARSER_LOAD 1
using namespace std;
/* The Admin class is responsible for reading source files and writing to output streams.
* It also performs white space and invisible character filtering on the input stream.
* It is generally an interface between files and the compiler.
*/
class Admin
{
private:
int linePos, lineCount;
bool traceScanner, traceParser, outputAST, almostDone;
string line, fileName;
ifstream * source;
ostream * output, * errOutput;
Scanner* sc;
Parser* ps;
SemanticAnalyzer* sa;
QuadrupleGenerator* qua;
bool isWhiteSpace(char c);
bool isInvisibleCharacter(char c);
public:
vector<Token> vec;
// Constructor/deconstructors/related
Admin(void);
Admin(ifstream & file, string fileName, ostream & out);
Admin(ifstream & file, string fileName, ostream & out, bool traceEnabled);
Admin(const Admin &other);
Admin& operator= (const Admin& rhs);
~Admin(void);
// Getters/setters
bool getOutputAST();
int getLineNumber();
void setOutputAST(bool outputAST);
void setOutputStream(ostream & out);
void setErrOutputStream(ostream & out);
// Logging functions
void scannerLog();
void scannerLogEnd();
void parserLog(string functionName, int mode);
void parserLog(int type, int mode);
void parserLog(ASTNode * topNode);
void syntaxError(string expected, int found);
void semanticError(string desc, int lineNumber);
void cancelAST();
// Other functions
void compile(int processTo);
void outputExecutable(vector<Quadruple> quads);
void enableOutputAST();
char getCh(bool skipWs);
void endLine();
void unget();
string getIdentifierName(int id);
};
#endif