Static Value-Flow Analysis
CFGNormalizer.h
Go to the documentation of this file.
1 //===----- CFGNormalizer.h -- Context Free Grammar Normalizer--------------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-> <Yulei Sui>
6 //
7 
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
17 
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //===----------------------------------------------------------------------===//
22 
23 /*
24  * CFGNormalizer.h
25  *
26  * Created on: April 19 , 2022
27  * Author: Pei Xu
28  */
29 
30 #ifndef INCLUDE_CFL_CFGNORMALIZER_H_
31 #define INCLUDE_CFL_CFGNORMALIZER_H_
32 
33 #include "CFGrammar.h"
34 
35 namespace SVF
36 {
37 
48 {
49 
50 public:
52  {
53  }
54 
56  CFGrammar* normalize(GrammarBase *generalGrammar);
57 
60 
61 private:
63  void ebnf_bin(CFGrammar *grammar);
64 
65  void ebnfSignReplace(char sign, CFGrammar *grammar);
66 
67  void barReplace(CFGrammar *grammar);
68 
70 
71  int ebnfBracketMatch(GrammarBase::Production& prod, int i, CFGrammar *grammar) ;
72 
74 
75  void strTrans(std::string strPro, CFGrammar *grammar, GrammarBase::Production& normalProd);
76 
77  void getFilledProductions(GrammarBase::Production &prod,const NodeSet& nodeSet, CFGrammar *grammar, GrammarBase::Productions& normalProds);
78 
79  void removeFirstSymbol(CFGrammar *grammar);
80 };
81 
82 } // End namespace SVF
83 
84 #endif /* INCLUDE_CFL_CFGNORMALIZER_H_*/
const char *const string
Definition: cJSON.h:172
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 * normalize(GrammarBase *generalGrammar)
Binary Normal Form(BNF) normalization with variable attribute expanded.
int ebnfBracketMatch(GrammarBase::Production &prod, int i, CFGrammar *grammar)
CFGrammar * fillAttribute(CFGrammar *grammar, const Map< CFGrammar::Kind, Set< CFGrammar::Attribute >> &kindToAttrsMap)
Expand every variable attribute in rawProductions of grammarbase.
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)
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > SymbolMap
Definition: CFGrammar.h:150
SymbolSet< Production > Productions
Definition: CFGrammar.h:157
std::vector< Symbol > Production
Definition: CFGrammar.h:156
for isBitcode
Definition: BasicTypes.h:68
Set< NodeID > NodeSet
Definition: GeneralType.h:113
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96