From cc38f338cc83abf82b2586599c0130053cebd5a5 Mon Sep 17 00:00:00 2001 From: andre ebersold Date: Tue, 18 Jun 2024 09:11:09 +0200 Subject: [PATCH] First time compile reqif work with visual studio 2022 --- CMakeLists.txt | 8 +- doc/reqif.xsd | 893 ++++++++++++++++++++++++ reqif.cpp | 12 +- src/properties/CMakeLists.txt | 8 +- src/properties/reference.lemon | 157 ++++- src/properties/reference_parser_base.h | 5 +- src/xml/reqif/reqif_element.h | 2 +- src/xml/reqif/reqif_elements_parser.cpp | 26 +- 8 files changed, 1065 insertions(+), 46 deletions(-) create mode 100644 doc/reqif.xsd diff --git a/CMakeLists.txt b/CMakeLists.txt index e387ce7..0d551c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,12 @@ IF(WIN32) ${CMAKE_BINARY_DIR}/lib/src/winexpat/expat ) SET(EXPAT_INCLUDE_DIR "${CMAKE_BINARY_DIR}/lib/installed/include" CACHE STRING "Expat include dir") - SET(EXPAT_LIBRARY "${CMAKE_BINARY_DIR}/lib/installed/lib/libexpat.lib" CACHE STRING "Expat library") - + MESSAGE(STATUS "Build Type : ${CMAKE_BUILD_TYPE}") + IF (WIN32 AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + SET(EXPAT_LIBRARY "${CMAKE_BINARY_DIR}/lib/installed/lib/libexpatd.lib" CACHE STRING "Expat library") + ELSE() + SET(EXPAT_LIBRARY "${CMAKE_BINARY_DIR}/lib/installed/lib/libexpat.lib" CACHE STRING "Expat library") + ENDIF() INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIR}) ELSE(WIN32) diff --git a/doc/reqif.xsd b/doc/reqif.xsd new file mode 100644 index 0000000..049db15 --- /dev/null +++ b/doc/reqif.xsd @@ -0,0 +1,893 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reqif.cpp b/reqif.cpp index c2ed284..c4d0fa0 100644 --- a/reqif.cpp +++ b/reqif.cpp @@ -27,10 +27,11 @@ void parse(const std::string &file) { + reqif::Element root_Elt; std::cout<<"Build Parser"< 1) + { + std::string fn(argv[1]); + std::cout<<" Try parsing "< #include +#include +#include +#include +#include +#include +#include +#include + + #include #include @@ -45,7 +54,7 @@ %syntax_error { printf("Syntax Error! Suggested tokens:\n"); - const YYACTIONTYPE stateno = yytos->stateno; + const YYACTIONTYPE stateno = yypParser->yytos->stateno; for (unsigned i = 0; i < YYNTOKEN; ++i) { int yyact = yy_find_shift_action(i, stateno); if (yyact != YY_ERROR_ACTION && yyact != YY_NO_ACTION) { @@ -64,16 +73,23 @@ std::unique_ptr reference_parser::create() { } -%token_type {Token &&} -%type function { antcc::condition::ICondition } -%type phrase { antcc:condition::ICondition::Result *} - +%token_type {Token } +%type function { antcc::condition::ICondition *} +%type function_if { antcc::condition::ICondition *} +%type function_not { antcc::condition::ICondition *} +%type function_or { antcc::condition::ICondition *} +%type function_and { antcc::condition::ICondition *} +%type function_isset { antcc::condition::ICondition *} +%type function_filter { antcc::condition::ICondition *} +%type function_filter_out { antcc::condition::ICondition *} +%type value { Token} +%type parameters { std::vector } value ::= . /* empty */ value ::= phrase(F). { - p->setResult(*F); - delete F; + //p->setResult(*F); + //delete F; } value ::= function(F). { @@ -85,76 +101,149 @@ value ::= function(F). { std::cout<<"TODO function no:"<<_result.m_Str<setResult(""); + //p->setResult(""); } +/* Phrase rules */ phrase(T)::=. -phrase(LH) ::= phrase(RH) chaine(STR). -phrase(LH) ::= phrase(RH) SPACE. -phrase(LH) ::= phrase(RH) global_reference(R). -phrase(LH) ::= phrase(RH) local_reference(R). +phrase(LH) ::= phrase(RH) chaine(STR). { + RH.stringValue.append(STR.stringValue); + LH = std::move(RH); +} +phrase(LH) ::= phrase(RH) SPACE. { + LH = std::move(RH); +} +phrase(LH) ::= phrase(RH) global_reference(R). { + LH = std::move(RH); +} +phrase(LH) ::= phrase(RH) local_reference(R). { + LH = std::move(RH); +} -global_reference(LH) ::= GLOBAL_REF_BEGIN fragment(F) REF_END. +global_reference(LH) ::= GLOBAL_REF_BEGIN fragment(F) REF_END. { + //p->lookup(*$2,_result); + //*$2 = _result; + LH = std::move(std::string("")); +} -local_reference(LH) ::= LOCAL_REF_BEGIN fragment(F) REF_END. +local_reference(LH) ::= LOCAL_REF_BEGIN fragment(F) REF_END. { + LH = std::move(F); +} -fragment(LH) ::= chaine(RH). +fragment(LH) ::= chaine(RH). { + LH = std::move(RH); +} -fragment(LH) ::= SPACE. +fragment(LH) ::= SPACE. { + LH = std::move(std::string("")); +} -fragment(LH) ::= chaine(CH) global_reference(GR). -fragment(LH) ::= global_reference(GR) chaine(CH). -fragment(LH) ::= local_reference(GR) chaine(CH). -fragment(LH) ::= fragment(RH) chaine(CH). -fragment(LH) ::= fragment(RH) SPACE. -fragment(LH) ::= fragment(RH) global_reference(GR). -fragment(LH) ::= fragment(RH) local_reference(LR). +fragment(LH) ::= chaine(CH) global_reference(GR). { + CH.stringValue.append(GR.stringValue); + LH = std::move(CH); +} +fragment(LH) ::= global_reference(GR) chaine(CH). { + GR.stringValue.append(CH.stringValue); + LH = std::move(GR); +} +fragment(LH) ::= local_reference(GR) chaine(CH). { + GR.stringValue.append(CH.stringValue); + LH = std::move(GR); +} +fragment(LH) ::= fragment(RH) chaine(CH). { + RH.stringValue.append(CH.stringValue); + LH = std::move(RH); +} +fragment(LH) ::= fragment(RH) SPACE. { + LH = std::move(RH); +} +fragment(LH) ::= fragment(RH) global_reference(GR). { + RH.stringValue.append(GR.stringValue); + LH = std::move(RH); +} +fragment(LH) ::= fragment(RH) local_reference(LR). { + RH.stringValue.append(LR.stringValue); + LH = std::move(RH); +} -fragment(LH) ::= global_reference(GR). -fragment(LH) ::= local_reference(LR). +fragment(LH) ::= global_reference(GR). { + LH = std::move(GR); +} +fragment(LH) ::= local_reference(LR). { + LH = std::move(LR); +} function(LF) ::= function_if(RF). +{ LF = RF ; } function(LF) ::= function_not(RF). +{ LF = RF ; } function(LF) ::= function_or(RF). +{ LF = RF ; } function(LF) ::= function_and(RF). +{ LF = RF ; } function(LF) ::= function_isset(RF). +{ LF = RF ; } function(LF) ::= function_filter(RF). +{ LF =RF ; } function(LF) ::= function_filter_out(RF). +{ LF = RF ; } function_if(LF) ::= IF three_parameters(PARAM) REF_END. +{ LF = NULL;} function_isset(LF) ::= ISSET parameter(PARAM) REF_END. +{ LF = NULL;} -function_not(LF) ::= NOT function(RFF) REF_END. +function_not(LF) ::= NOT function(RFF) REF_END. { + antcc::condition::condition_not *_cond = new + antcc::condition::condition_not(RFF); + LF = _cond; +} function_or(LF) ::= OR parameters(PARAM) REF_END. +{ LF = NULL;} function_and(LF) ::= AND parameters(PARAM) REF_END. +{ LF = NULL;} function_filter(LF) ::= FILTER three_parameters(PARAM) REF_END. +{ LF = NULL;} +function_filter_out(LF) ::= FILTER_OUT three_parameters(PARAM) REF_END. { + LF = NULL; +} -function_filter_out(LF) ::= FILTER_OUT three_parameters(PARAM) REF_END. +parameter(LP) ::= global_reference(RH). { + LP = std::move(RH); +} +parameter(LP) ::= local_reference(RH). { + LP = std::move(RH); +} -parameter(LP) ::= global_reference(RH). -parameter(LP) ::= local_reference(RH). +parameter(LP) ::= chaine(CH). { + LP = CH; +} -parameter(LP) ::= chaine(CH). +parameters(LH) ::= parameter(RH). { + LH.push_back(RH.stringValue); +} -parameters(LH) ::= parameter(RH). -parameters(LH) ::= parameters(RH) VIRGULE parameter(RP). +parameters(LH) ::= parameters(RH) VIRGULE parameter(RP). { + RH.push_back(RP.stringValue); + LH = RH; +} three_parameters(LH) ::= parameter VIRGULE parameter VIRGULE parameter. chaine(RH)::= CHAINE(T). { - RH = T; + RH = std::move(T); } chaine(RH)::= WORD(T). { - RH = T; + RH = std::move(T); } diff --git a/src/properties/reference_parser_base.h b/src/properties/reference_parser_base.h index 4c00301..28c8791 100644 --- a/src/properties/reference_parser_base.h +++ b/src/properties/reference_parser_base.h @@ -10,7 +10,7 @@ struct Token { Token() = default; Token(const Token &) = default; Token(Token &&) = default; - + virtual ~Token() {} ; Token(int i) : intValue(i) {} Token(const std::string &s) : stringValue(s) @@ -19,7 +19,8 @@ struct Token { {} - Token& operator=(const Token &) = default; + //Token& operator=(const Token &) = default; + Token& operator=(const Token &t) {intValue = t.intValue; stringValue = t.stringValue; return *this;}; Token& operator=(Token &&) = default; int intValue = 0; diff --git a/src/xml/reqif/reqif_element.h b/src/xml/reqif/reqif_element.h index afe289d..a49a005 100644 --- a/src/xml/reqif/reqif_element.h +++ b/src/xml/reqif/reqif_element.h @@ -30,7 +30,7 @@ namespace reqif { typedef typename xml::element_traits::element_type t_type; typedef typename xml::element_traits::element_sptr t_sptr; - Element(int _type ) : m_Name("") , m_Type(_type) {} + Element(int _type = eNone) : m_Name("") , m_Type(_type) {} Element(const Element &_e) : m_Name(_e.m_Name),m_Type(_e.m_Type) {} diff --git a/src/xml/reqif/reqif_elements_parser.cpp b/src/xml/reqif/reqif_elements_parser.cpp index ea0d852..eed7e4a 100644 --- a/src/xml/reqif/reqif_elements_parser.cpp +++ b/src/xml/reqif/reqif_elements_parser.cpp @@ -578,7 +578,7 @@ ROOT_PARSER(ReqifParser, { if (name == "THE-HEADER" && ns.empty()) { - s.m_parser = SHARED_PTR(new TargetParser(m_Project + s.m_parser = SHARED_PTR(new ReqifHeaderParser(m_Project , ::reqif::ElementFactory::get().orderElement(name.c_str()) )); } else if (name == "TOOL-EXTENSION" && ns.empty()) @@ -797,6 +797,30 @@ COMPLEX_PARSER(SpecObjectTypeParser, return l_ok; }) +// Spec Object Type Parser Implementation +COMPLEX_PARSER(SpecAttributesParser, + { + s.m_parser = SHARED_PTR(new AttributeDefinitionParser(m_Project + , ::reqif::ElementFactory::get().orderElement(name.c_str()) + )); + return true; + + } + , + { + ANTCC_PARSER_DEBUG_TASK("SpecAttributesParser end %s size=%u" + ,name.c_str() + ,m_context.size()); + return true; + } + , + { + ANTCC_PARSER_DEBUG_TASK("SpecAttributesParser Attribute: %s-> %s" + ,name.c_str() + ,val.c_str()); + return l_ok; + }) + // Macrodef Parser Implementation COMPLEX_PARSER(AttributeDefinitionParser, -- 2.30.2