forked from rperlste/UniversalCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompilerStackObject.h
57 lines (44 loc) · 1.06 KB
/
CompilerStackObject.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
#ifndef _CompilerStackObject
#define _CompilerStackObject
#include <string>
#include <stack>
#include "ActionSymbols.h"
#include "EndOfProduction.h"
#include "Production.h"
#include "SemanticRecord.h"
typedef std::string Symbol;
enum StackObjectType {
ActionSymbolEnum,
SymbolEnum,
EOPEnum,
SemanticRecordEnum
};
struct StackObject{
StackObject(){}
StackObject( ActionSymbols::ActionSymbol actionSymbol ){
this->actionSymbol = actionSymbol;
type = ActionSymbolEnum;
}
StackObject( Symbol symbol ){
this->symbol = symbol;
if( !symbol.empty() && symbol[0] == '#' ){
type = ActionSymbolEnum;
} else {
type = SymbolEnum;
}
}
StackObject( EndOfProduction EOP ){
this->EOP = EOP;
type = EOPEnum;
}
StackObject( SemanticRecord semanticRecord ){
this->semanticRecord = semanticRecord;
type = SemanticRecordEnum;
}
ActionSymbols::ActionSymbol actionSymbol;
Symbol symbol;
EndOfProduction EOP;
SemanticRecord semanticRecord;
StackObjectType type;
};
#endif