-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compiler.h
78 lines (58 loc) · 1.59 KB
/
Compiler.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
#ifndef SS_COMPILER_H
#define SS_COMPILER_H
#include "Prereqs.h"
namespace SS {
class Package;
class FileInfo;
enum CompilerMsgType
{
MSG_WARNING,
MSG_ERROR,
MSG_INFO
};
struct CompilerMessage
{
public:
CompilerMessage() : m_msgType(MSG_INFO), m_file(0), m_line(0) {}
String Format() const;
SS_GETSET(CompilerMsgType, MessageType, m_msgType);
SS_GETSET(FileInfo*, File, m_file);
SS_GETSET(int, Line, m_line);
SS_GETSET(const String&, Text, m_text);
private:
CompilerMsgType m_msgType;
FileInfo* m_file;
int m_line;
String m_text;
};
class SS_EXPORT ICompilationListener
{
public:
virtual ~ICompilationListener() {}
virtual void OnCompilerMessage(const CompilerMessage& msg)=0;
};
class SS_EXPORT Compiler
{
public:
Compiler();
virtual ~Compiler();
ICompilationListener* GetCompilationListener() const { return m_listener; }
void SetCompilationListener(ICompilationListener* listener) { m_listener = listener; }
void Parse(const String& filename, const String& scriptText);
void Parse(const String& filename, std::istream& scriptStream);
Package* Compile(const String& pkgName);
int GetWarningCount() const { return m_warnings; }
int GetErrorCount() const { return m_errors; }
bool Succeeded() const { return m_succeeded; }
void ReportMessage(const CompilerMessage& msg);
private:
bool m_compiled;
int m_errors;
int m_warnings;
bool m_succeeded;
Package* m_pkg;
ICompilationListener* m_listener;
};
SS_EXPORT Compiler* GetActiveCompiler();
}
#endif // SS_COMPILER_H