64 for (
auto pair: kindToAttrsMap)
68 nodeSet.insert(
attri);
99 for(
auto itr : rawProductions)
102 for(
auto rule: head.second)
104 if (
rule.size() < 3)
continue;
115 if ((
X ==
u32_t(-1)) ==
false)
123 std::ostringstream
ss;
134 if ( variableAttribute != 0)
179 std::ostringstream
ss;
186 if ( variableAttribute != 0)
228 while( worklist.
empty() ==
false )
249 for (
auto attribute : nodeSet)
256 symbol.attribute = attribute;
257 symbol.variableAttribute = 0;
264 if (
symbol.variableAttribute != 0 )
344 assert(
i != 1 &&
"sign in grammar associate with no symbol");
378 std::ostringstream
ss;
440 size_t start =
LHS.find_first_not_of(
" \t\n\r");
442 if (
start != std::string::npos)
459 word =
LHS.substr(0,
pos);
486 if (
prod.size() == 2)
500 if (
prod.size() == 3)
512 for(
auto rule: head.second)
void barReplace(CFGrammar *grammar)
void ebnf_bin(CFGrammar *grammar)
Add nonterminal to tranfer long rules to binary rules.
void ebnfSignReplace(char sign, CFGrammar *grammar)
void insertToCFLGrammar(CFGrammar *grammar, GrammarBase::Production &prod)
Based on prod size to add on suitable member field of grammar.
void removeFirstSymbol(CFGrammar *grammar)
CFGrammar * fillAttribute(CFGrammar *grammar, const Map< CFGrammar::Kind, Set< CFGrammar::Attribute > > &kindToAttrsMap)
Expand every variable attribute in rawProductions of grammarbase.
CFGrammar * normalize(GrammarBase *generalGrammar)
Binary Normal Form(BNF) normalization with variable attribute expanded.
int ebnfBracketMatch(GrammarBase::Production &prod, int i, CFGrammar *grammar)
void getFilledProductions(GrammarBase::Production &prod, const NodeSet &nodeSet, CFGrammar *grammar, GrammarBase::Productions &normalProds)
void strTrans(std::string strPro, CFGrammar *grammar, GrammarBase::Production &normalProd)
GrammarBase::Symbol check_head(GrammarBase::SymbolMap< GrammarBase::Symbol, GrammarBase::Productions > &grammar, GrammarBase::Production &rule)
SymbolMap< Symbol, Productions > & getFirstRHSToProds()
SymbolMap< Symbol, Productions > & getSingleRHSToProds()
const u32_t num_generator()
SymbolMap< Symbol, Productions > & getSecondRHSToProds()
Productions & getEpsilonProds()
void setStartKind(Kind startKind)
void setAttributeKinds(const Set< Kind > &attributeKind)
const Map< Kind, Set< Attribute > > & getKindToAttrsMap() const
void setRawProductions(SymbolMap< Symbol, Productions > &rawProductions)
void setTotalKind(Kind totalKind)
Kind strToKind(std::string str) const
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > SymbolMap
Symbol strToSymbol(const std::string str) const
Symbol insertNonTerminalSymbol(std::string strLit)
SymbolMap< Symbol, Productions > & getRawProductions()
SymbolSet< Production > Productions
void setKindToAttrsMap(const Map< Kind, Set< Attribute > > &kindToAttrsMap)
std::string kindToStr(Kind kind) const
void setEBNFSigns(Map< std::string, Kind > &EBNFSigns)
void setTerminals(Map< std::string, Kind > &terminals)
std::vector< Symbol > Production
void setNonterminals(Map< std::string, Kind > &nonterminals)
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder