Static Value-Flow Analysis
|
#include <CFGNormalizer.h>
Public Member Functions | |
CFGNormalizer () | |
CFGrammar * | normalize (GrammarBase *generalGrammar) |
Binary Normal Form(BNF) normalization with variable attribute expanded. | |
CFGrammar * | fillAttribute (CFGrammar *grammar, const Map< CFGrammar::Kind, Set< CFGrammar::Attribute > > &kindToAttrsMap) |
Expand every variable attribute in rawProductions of grammarbase. | |
Private Member Functions | |
void | ebnf_bin (CFGrammar *grammar) |
Add nonterminal to tranfer long rules to binary rules. | |
void | ebnfSignReplace (char sign, CFGrammar *grammar) |
void | barReplace (CFGrammar *grammar) |
void | insertToCFLGrammar (CFGrammar *grammar, GrammarBase::Production &prod) |
Based on prod size to add on suitable member field of grammar. | |
int | ebnfBracketMatch (GrammarBase::Production &prod, int i, CFGrammar *grammar) |
GrammarBase::Symbol | check_head (GrammarBase::SymbolMap< GrammarBase::Symbol, GrammarBase::Productions > &grammar, GrammarBase::Production &rule) |
void | strTrans (std::string strPro, CFGrammar *grammar, GrammarBase::Production &normalProd) |
void | getFilledProductions (GrammarBase::Production &prod, const NodeSet &nodeSet, CFGrammar *grammar, GrammarBase::Productions &normalProds) |
void | removeFirstSymbol (CFGrammar *grammar) |
Generate Normalized Grammar (backus naur form) from a grammarbase (Extended extended Backus–Naur form )
To Do: Error Notice for ill formed production, e.g. not end with ';' and '*' not preceding with '()' and extra space before ';' '|' sign support
Definition at line 47 of file CFGNormalizer.h.
|
inline |
Definition at line 51 of file CFGNormalizer.h.
|
private |
Definition at line 295 of file CFGNormalizer.cpp.
|
private |
Definition at line 467 of file CFGNormalizer.cpp.
|
private |
Add nonterminal to tranfer long rules to binary rules.
Assign _attribute if target portion of the production contain more than 1 variable then X add no variable attribute if target only contain one variable attribute X share the same variable attribute
Definition at line 91 of file CFGNormalizer.cpp.
|
private |
Replace Sign Group With tempNonterminal 'X' And load the replace in newProductions
If sign associate without group e.i with single symbol
sign associate with group of symbol by brace pair
For Both * and ? need to insert epsilon rule
insert second rule for '*' X -> X E for '+' X -> E
Insert Back the Group
Definition at line 325 of file CFGNormalizer.cpp.
CFGrammar * CFGNormalizer::fillAttribute | ( | CFGrammar * | grammar, |
const Map< CFGrammar::Kind, Set< CFGrammar::Attribute > > & | kindToAttrsMap | ||
) |
Expand every variable attribute in rawProductions of grammarbase.
rawProductions production does not include lhs so append to the begin of the production
Definition at line 61 of file CFGNormalizer.cpp.
|
private |
Loop through provided production based on existence of attribute of attribute variable and expand to productions set e.g Xi -> Y Zi with Xi i = 0, 1, Yi i = 0,2 Will get {X0 -> Y Z0, X1 -> Y Z1, X2 -> Y Z2}
Get the first encounter variable attribute to expand
Check whether all symbol expanded
Definition at line 223 of file CFGNormalizer.cpp.
|
private |
Based on prod size to add on suitable member field of grammar.
Definition at line 484 of file CFGNormalizer.cpp.
CFGrammar * CFGNormalizer::normalize | ( | GrammarBase * | generalGrammar | ) |
Binary Normal Form(BNF) normalization with variable attribute expanded.
Definition at line 41 of file CFGNormalizer.cpp.
|
private |
Definition at line 507 of file CFGNormalizer.cpp.
|
private |
Definition at line 437 of file CFGNormalizer.cpp.