-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate_collection.cpp
61 lines (57 loc) · 1.47 KB
/
state_collection.cpp
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
#include "state_collection.h"
StateCollection::StateCollection() {
}
StateCollection::~StateCollection() {
foreach (State *s, states.values()) {
delete s;
}
}
State* StateCollection::get(StateType type){
if (states.contains(type))
return states[type];
else {
State *s;
switch (type) {
case stateLexStatement:
s = new LexStatement();
break;
case stateLexSpace:
s = new LexSpace();
break;
case stateLexExclamation:
s = new LexExclamation();
break;
case stateLexLessThan:
s = new LexLessThan();
break;
case stateLexMultiLineComment:
s = new LexMultiLineComment();
break;
case stateLexComment:
s = new LexComment();
break;
case stateLexBracketedIdentifier:
s = new LexBracketedIdentifier();
break;
case stateLexQuotedIdentifier:
s = new LexQuotedIdentifier();
break;
case stateLexString:
s = new LexString();
break;
case stateLexUnicodeString:
s = new LexUnicodeString();
break;
case stateLexIdentifier:
s = new LexIdentifier();
break;
case stateLexNumber:
s = new LexNumber();
break;
default:
throw;
}
states[type] = s;
return s;
}
}