Commit 80d22609 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add test and avoid generating dead code (for operator essentially)

parent 00129d8a
Pipeline #99363 passed with stages
in 7 minutes and 25 seconds
......@@ -48,6 +48,9 @@ int printShadokFile(const std::string & fileName){
//We get the parsed internal representation
Source & source = parser.getSourceS();
std::string sourceStr(gSource(source));
std::cout << "printShadokFile : source converted to string = '"<<sourceStr<<"'" << std::endl;
std::vector<Shadok> & vecShadok = Source_getVecShadok(source).getVecStmt();
if(vecShadok.size() == listShadokAge.size()){
......
......@@ -53,16 +53,17 @@ std::string repr_cpp_operatorHeader(const PTabGraphToken & tabGraphToken){
//Create all the define
const PVecOperator & vecOperator = tabGraphToken.getVecOperator();
for(PVecOperator::const_iterator it(vecOperator.begin()); it != vecOperator.end(); ++it){
body += "//Define the priority of the operator " + it->getValueEnum() + "\n";
body += "#define OPERATOR_PRIORITY_" + repr_cpp_operator_getEnumValue(it->getValueEnum())+ " " + convertToString(it->getOpPriority()) + "\n\n";
if(vecOperator.size() != 0lu){
for(PVecOperator::const_iterator it(vecOperator.begin()); it != vecOperator.end(); ++it){
body += "//Define the priority of the operator " + it->getValueEnum() + "\n";
body += "#define OPERATOR_PRIORITY_" + repr_cpp_operator_getEnumValue(it->getValueEnum())+ " " + convertToString(it->getOpPriority()) + "\n\n";
}
body += "\n";
body += "bool isAnOperator(const PStmt & _op);\n";
body += "long get_priority_operator(const PStmt & _op);\n";
body += "PStmt* get_last_operand_of_operator(PStmt & _op);\n";
body += "PStmt* get_first_operand_of_operator(PStmt & _op);\n";
}
body += "\n";
body += "bool isAnOperator(const PStmt & _op);\n";
body += "long get_priority_operator(const PStmt & _op);\n";
body += "PStmt* get_last_operand_of_operator(PStmt & _op);\n";
body += "PStmt* get_first_operand_of_operator(PStmt & _op);\n";
body += "\n\n";
body += "#endif\n\n\n";
return body;
......@@ -77,8 +78,11 @@ std::string repr_cpp_operatorSource(const PTabGraphToken & tabGraphToken, const
body += licenceSaveStr();
body += "#include \""+baseFileName+".h\"\n\n";
const PVecOperator & vecOperator = tabGraphToken.getVecOperator();
if(vecOperator.size() == 0lu){return body;}
PMapVecOperator mapOp;
repr_cpp_operatorGetClass(mapOp, tabGraphToken.getVecOperator());
repr_cpp_operatorGetClass(mapOp, vecOperator);
body += "///Say if the given PStmt is an operator\n";
body += "/**\t@param _op : PStmt to be checked\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment