-
Notifications
You must be signed in to change notification settings - Fork 3
/
Scanner.hpp
65 lines (49 loc) · 1.42 KB
/
Scanner.hpp
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
#ifndef SoftWire_Scanner_hpp
#define SoftWire_Scanner_hpp
#include "TokenList.hpp"
#include "Link.hpp"
namespace SoftWire
{
class Scanner : public TokenList
{
public:
Scanner();
Scanner(const char *fileName, bool doPreprocessing = true);
~Scanner();
void scanFile(const char *fileName, bool doPreprocessing = true);
void scanString(const char *sourceString, bool doPreprocessing = true);
static void defineSymbol(int value, const char *name);
static void clearSymbols();
private:
struct Symbol
{
Symbol(int value = 0, const char *name = 0) : value(value), name(name) {};
int value;
const char *name;
};
char *source;
enum {tokenMax = 256}; // Maximum token length
typedef Link<Symbol> SymbolTable;
static SymbolTable *symbols;
void scanBuffer(char *source, bool doPreprocessing);
void preprocess();
void includeFiles();
void substituteSymbols();
void expandMacros();
void conditionalCompilation();
int conditionTrue();
void evaluateUnary();
void evaluateMultiplicative();
void evaluateAdditive();
void evaluateRelational();
void evaluateEquality();
void evaluateBitwiseAND();
void evaluateBitwiseOR();
void evaluateLogicalAND();
void evaluateLogicalOR();
void processDirectives();
bool cleanupParenthesis();
void includeFile(const char *fileName);
};
}
#endif // SoftWire_Scanner_hpp