Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 146586c0 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Start to take account operator priority in parsing

parent 9103e7b2
......@@ -20,3 +20,5 @@ add_test(NAME Test_test_math_operator_parser_input
add_test(NAME Test_test_math_operator_parser_input3
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_math_operator_parser_input -i ${CMAKE_CURRENT_SOURCE_DIR}/fileAdd3.math -r "(a+(b+c))"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
......@@ -654,9 +654,10 @@ std::string graph_cpp_vecGraphDeclInternalRepresentationHeader(const PVecGraphTo
///Save the two header and source files of a PTabGraphToken
/** @param tabGraphToken : PTabGraphToken to be saved
* @param baseFileName : base name of the current file
* @return full header
*/
std::string graph_cpp_tabGraphTokenParserHeader(const PTabGraphToken & tabGraphToken){
std::string graph_cpp_tabGraphTokenParserHeader(const PTabGraphToken & tabGraphToken, const std::string & baseFileName){
std::string body("");
body += licenceSaveStr();
std::string mainParser(tabGraphToken.getName());
......@@ -668,6 +669,7 @@ std::string graph_cpp_tabGraphTokenParserHeader(const PTabGraphToken & tabGraphT
body += "#include <string>\n";
body += "#include <vector>\n";
body += "#include \"PMultiFileParser.h\"\n";
body += "#include \""+baseFileName+"Operator.h\"\n";
body += "\n";
const PVecSourceToken & vecSource = tabGraphToken.getVecSource();
......@@ -1010,7 +1012,7 @@ bool graph_cpp_tabGraphTokenParser(const PTabGraphToken & tabGraphToken){
std::string fileHeader(baseFileName + ".h");
std::string fileSource(baseFileName + ".cpp");
std::string headerStr(graph_cpp_tabGraphTokenParserHeader(tabGraphToken));
std::string headerStr(graph_cpp_tabGraphTokenParserHeader(tabGraphToken, baseFileName));
std::string sourceStr(graph_cpp_tabGraphTokenParserSource(tabGraphToken));
if(!saveFileContent(fileHeader, headerStr)){
......@@ -1052,7 +1054,6 @@ bool graph_cpp_tabGraphTokenParserFull(const PTabGraphToken & tabGraphToken){
}
}
body += "\n";
body += "#include \""+baseFileName+"Operator.h\"\n";
body += "#include \""+baseFileName+"_to_language.h\"\n";
body += "#include \""+baseFileName+".h\"\n";
......
......@@ -50,15 +50,26 @@ std::string repr_cpp_singleTokenOperator(const POperator & op, const PGraphToken
body += "\t//repr_cpp_token_operator : here the operator is well parsed\n";
body += "\tPStmt op = "+op.getExprClass()+"_default();\n";
// body += "\top.setType("+op.getValueEnum()+");\n";
body += "\t"+op.getExprClass()+"_set"+firstToUpper(op.getAttrEnum())+"(op, "+op.getValueEnum()+");\n";
body += "\tPStmt & vecOperand = PExpr_getVecOperand(op);\n";
body += "\tvecOperand.push_back("+varName+");\n";
body += "\tvecOperand.push_back(rightOp);\n";
body += "\t//repr_cpp_token_operator : Finally, put the operator in the in/out parameter\n";
body += "\t"+varName+" = op;\n";
body += "\t\n";
body += "\tbool isStandardPushBack(true);\n";
body += "\tif(isAnOperator(e)){\n";
body += "\t\tlong priorityOp(get_priority_operator(op)), priorityInput(get_priority_operator("+varName+"));\n";
body += "\t\tif(priorityOp > priorityInput){\n";
body += "\t\t\t//repr_cpp_token_operator : Let's get the last operand of the input "+varName+"\n";
body += "\t\t\t\n";
body += "\t\t\t\n";
body += "\t\t\t\n";
body += "\t\t\tisStandardPushBack = false;\n";
body += "\t\t}\n";
body += "\t}\n";
body += "\tif(isStandardPushBack){\n";
body += "\t\tvecOperand.push_back("+varName+");\n";
body += "\t\tvecOperand.push_back(rightOp);\n";
body += "\t\t//repr_cpp_token_operator : Finally, put the operator in the in/out parameter\n";
body += "\t\t"+varName+" = op;\n";
body += "\t}\n";
return body;
}
......@@ -117,7 +128,7 @@ std::string repr_cpp_tokenOperatorSourceOperatorDo(const std::string & parserNam
body += "\t//repr_cpp_token_operator : If there is no operand\n";
body += "\tif(_vecOp.size() == 0lu){return false;}\n";
body +="\treturn false;\n";
body +="\treturn true;\n";
body +="}\n\n";
return body;
}
......
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