57 static_assert(
sizeof(
struct Symbol)==
sizeof(
u32_t),
"sizeof(struct Symbol)!=sizeof(u32_t)");
67 static_assert(
sizeof(
struct Symbol)==
sizeof(
u32_t),
"sizeof(struct Symbol)!=sizeof(u32_t)");
89 this->
kind = num & 0xFF;
96 return ((this->
kind == s.
kind) && (
this->attribute ==
s.attribute) && (
this->variableAttribute ==
s.variableAttribute));
106 return ! (*
this ==
s) ;
116 return (this->
kind == k);
140 h ^=
hf(t) + 0x9e3779b9 + (
h << 6) + (
h >> 2);
147 template<
typename Key,
typename Value,
typename Hash = SymbolHash,
148 typename KeyEqual = std::equal_to<Key>,
149 typename Allocator = std::allocator<std::pair<const Key, Value>>>
150 using SymbolMap = std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>;
152 template <
typename Key,
typename Hash = SymbolVectorHash,
typename KeyEqual = std::equal_to<Key>,
153 typename Allocator = std::allocator<Key>>
154 using SymbolSet = std::unordered_set<Key, Hash, KeyEqual, Allocator>;
385 void dump(std::string fileName)
const;
SymbolMap< Symbol, Productions > firstRHSToProds
SymbolMap< Symbol, Productions > & getFirstRHSToProds()
const Symbol & getFirstRHSSymbol(const Production &prod) const
const Productions & getProdsFromFirstRHS(const Symbol sym) const
const Symbol & getSecondRHSSymbol(const Production &prod) const
SymbolMap< Symbol, Productions > & getSingleRHSToProds()
const u32_t num_generator()
SymbolMap< Symbol, Productions > & getSecondRHSToProds()
Productions & getEpsilonProds()
SymbolSet< Production > epsilonProds
const bool hasProdsFromFirstRHS(const Symbol sym) const
const bool hasProdsFromSecondRHS(const Symbol sym) const
const Symbol & getLHSSymbol(const Production &prod) const
SymbolMap< Symbol, Productions > singleRHSToProds
static bool classof(const GrammarBase *node)
static bool classof(const CFGrammar *)
Methods for support type inquiry through isa, cast, and dyn_cast:
const Productions & getProdsFromSecondRHS(const Symbol sym) const
SymbolMap< Symbol, Productions > secondRHSToProds
const Productions & getProdsFromSingleRHS(const Symbol sym) const
u32_t newTerminalSubscript
const bool hasProdsFromSingleRHS(const Symbol sym) const
GrammarBase::SymbolSet< Data > DataSet
bool find(Data data) const
DataDeque data_list
work list using std::vector.
DataSet data_set
store all data in the work list.
std::deque< Data > DataDeque
size_t operator()(const Symbol &s) const
Map< std::string, Kind > terminals
std::string extractAttributeStrFromSymbolStr(const std::string &symbolStr) const
void setStartKind(Kind startKind)
void setAttributeKinds(const Set< Kind > &attributeKind)
const Map< Kind, Set< Attribute > > & getKindToAttrsMap() const
Symbol insertEBNFSigns(std::string strLit)
static constexpr unsigned char AttributedKindMaskBits
We use the lower 24 bits to denote attributed kind.
void setRawProductions(SymbolMap< Symbol, Productions > &rawProductions)
std::string extractKindStrFromSymbolStr(const std::string &symbolStr) const
void setTotalKind(Kind totalKind)
Kind strToKind(std::string str) const
Symbol insertSymbol(std::string strLit)
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > SymbolMap
Symbol strToSymbol(const std::string str) const
std::string symToStrDump(Symbol sym) const
Map< std::string, Kind > & getEBNFSigns()
Map< std::string, Kind > & getNonterminals()
SymbolMap< Symbol, Productions > rawProductions
Symbol insertNonTerminalSymbol(std::string strLit)
SymbolMap< Symbol, Productions > & getRawProductions()
Map< std::string, Kind > & getTerminals()
SymbolSet< Production > Productions
Symbol insertTerminalSymbol(std::string strLit)
Map< Kind, Set< Attribute > > kindToAttrsMap
Map< std::string, Kind > EBNFSigns
const Set< Kind > & getAttrSyms() const
std::unordered_set< Key, Hash, KeyEqual, Allocator > SymbolSet
static constexpr u64_t EdgeKindMask
void insertAttribute(Kind kind, Attribute a)
Map< std::string, Kind > nonterminals
Kind insertNonterminalKind(std::string const kindStr)
Insert kind to nonterminal and return kind.
Set< Kind > attributeKinds
Map contains Signs' String and associated Symbols.
void setKindToAttrsMap(const Map< Kind, Set< Attribute > > &kindToAttrsMap)
std::string kindToStr(Kind kind) const
Kind insertTerminalKind(std::string strLit)
static Kind getVariabledKind(VariableAttribute variableAttribute, Kind kind)
void setEBNFSigns(Map< std::string, Kind > &EBNFSigns)
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
void setTerminals(Map< std::string, Kind > &terminals)
std::vector< Symbol > Production
static Kind getAttributedKind(Attribute attribute, Kind kind)
Symbol getSymbol(const Production &prod, u32_t pos)
void setNonterminals(Map< std::string, Kind > &nonterminals)
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::Value Value
LLVM Basic classes.
llvm::IRBuilder IRBuilder
size_t operator()(const std::vector< Symbol > &v) const
bool operator<(const Symbol &rhs)
bool operator==(const Symbol &s)
bool operator!=(const Symbol &s) const
void operator=(const u32_t &i)
bool operator==(const Kind &k) const
bool operator==(const Symbol &s) const
Symbol(const u32_t &num)
Construct from u32_t move the bit to right field.
void operator=(unsigned long long num)
bool operator==(const u32_t &i)
Symbol()
Default Value for Symbol is 0.
VariableAttribute variableAttribute
provide extra hash function for std::pair handling