forked from rperlste/UniversalCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPredictSet.h
36 lines (30 loc) · 1.04 KB
/
PredictSet.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
#ifndef _PredictSet
#define _PredictSet
#include <string>
#include "Production.h"
#include "GrammarSet.h"
#include "IndexedMap.h"
class PredictSet : public IndexedMap< Production, GrammarSet > {
public:
bool setUnion( Production& production, Symbol& predictValue );
bool setUnion( Production& production, GrammarSet& predictValues );
};
// Return true if change occurred, false if none occurred
bool PredictSet::setUnion( Production& production, Symbol& predictValue ){
GrammarSet tempGrammarSet;
tempGrammarSet.insert( predictValue );
if( this->find( production ) == this->end() ){
return this->insert( production, tempGrammarSet );
} else {
return this->getValueByKey( production ).setUnion( tempGrammarSet );
}
}
// Return true if change occurred, false if none occurred
bool PredictSet::setUnion( Production& production, GrammarSet& predictValues ){
if( this->find( production ) == this->end() ){
return this->insert( production, predictValues );
} else {
return this->getValueByKey( production ).setUnion( predictValues );
}
}
#endif