Started windows build with ragel and lemon
authorandre ebersold <andre.ebersold@siemens.com>
Thu, 13 Jun 2024 13:02:10 +0000 (15:02 +0200)
committerandre ebersold <andre.ebersold@siemens.com>
Thu, 13 Jun 2024 13:02:10 +0000 (15:02 +0200)
CMakeLists.txt
rules
src/properties/CMakeLists.txt
src/properties/reference.lemon [new file with mode: 0644]
src/properties/reference_lexer.ragel [new file with mode: 0644]
src/properties/reference_parser_base.h [new file with mode: 0644]
src/xml/CMakeLists.txt
utils

index 60a62b39da4ea82a2a901f84da2c61b1f5f8a0ce..e387ce7005beafc036304c19de162825990939bb 100644 (file)
@@ -87,6 +87,10 @@ OPTION(ANTCC_OPTION_INSTALL               "Build antcc docs" OFF)
 OPTION(ANTCC_BUILD_TESTS "Build antcc tests" OFF)
 OPTION(ANTCC_BUILD_DOCS  "Build antcc docs" OFF)
 
+OPTION(ANTCC_USE_LEMON   "Use Lemon/ragel instead of flex bison" ON)
+
+find_program(RAGEL NAMES ragel ragel.exe PATHS c:/msys64/mingw64/bin ENV)
+
 # new way
 CONFIGURE_FILE(${antcc_SOURCE_DIR}/src/antcc/config.h.cmake
        ${antcc_BINARY_DIR}/src/antcc/config.h)
@@ -164,4 +168,7 @@ MESSAGE(STATUS "")
 MESSAGE(STATUS "  Features")
 MESSAGE(STATUS "    Use boost ............ ${ANTCC_WITH_BOOST}")
 MESSAGE(STATUS "    Use aeb .............. ${ANTCC_WITH_AEB}")
+MESSAGE(STATUS "")
+MESSAGE(STATUS "  Programs")
+MESSAGE(STATUS "    Use ragel ............ ${RAGEL}")
 MESSAGE(STATUS "==============================================================")
diff --git a/rules b/rules
index aeca878a84169490996e427211493ac306f00c7c..bd52bb81d0b9b6d93a31d3d78801798e13d05a8a 160000 (submodule)
--- a/rules
+++ b/rules
@@ -1 +1 @@
-Subproject commit aeca878a84169490996e427211493ac306f00c7c
+Subproject commit bd52bb81d0b9b6d93a31d3d78801798e13d05a8a
index cf7226fa8701cda2490286194e962143b338fd93..9c229fa3aad5787b8ef0b2c9aedea3d69018df76 100644 (file)
@@ -11,21 +11,35 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
 INCLUDE_DIRECTORIES(${aebutils_SOURCE_DIR})
 # For option...
 INCLUDE_DIRECTORIES(${aebutils_SOURCE_DIR}/aeb)
-    
-FLEXGEN(SOURCE reference.l OUTPUT ref_l.cpp OPTS -R )
-BISONGEN(reference.y ref_y.cpp cpp)
+
+set(PLIB_GEN_SRCS "")
+
+if(ANTCC_USE_LEMON)
+  RAGELGEN(SOURCE reference_lexer.ragel OUTPUT ref_l.cpp)
+  LEMONGEN(SOURCE reference.lemon OUTPUT reference.c)
+  list(APPEND PLIB_GEN_SRCS ${CMAKE_CURRENT_BINARY_DIR}/reference.c)
+  list(APPEND PLIB_GEN_SRCS ${CMAKE_CURRENT_BINARY_DIR}/ref_l.cpp)
+else()
+  FLEXGEN(SOURCE reference.l OUTPUT ref_l.cpp OPTS -R )
+  BISONGEN(reference.y ref_y.cpp cpp)
+  list(APPEND PLIB_GEN_SRCS ${CMAKE_CURRENT_BINARY_DIR}/ref_y.cpp)
+  list(APPEND PLIB_GEN_SRCS ${CMAKE_CURRENT_BINARY_DIR}/ref_l.cpp)
+endif()
+
+
+
+
+
 
 ADD_LIBRARY(propertylib
     reference_parser.cpp 
     property_file.cpp
-    ${CMAKE_CURRENT_BINARY_DIR}/ref_l.cpp
-    ${CMAKE_CURRENT_BINARY_DIR}/ref_y.cpp
+    ${PLIB_GEN_SRCS}
     ) 
 
 ADD_EXECUTABLE(test_prop_parser
     reference_parser.cpp 
-    ${CMAKE_CURRENT_BINARY_DIR}/ref_y.cpp
-    ${CMAKE_CURRENT_BINARY_DIR}/ref_l.cpp
+    ${PLIB_GEN_SRCS}
 )
 
 TARGET_LINK_LIBRARIES(test_prop_parser libantcc_parser libantcc_cond libantcc ${EXPAT_LIBRARY})
diff --git a/src/properties/reference.lemon b/src/properties/reference.lemon
new file mode 100644 (file)
index 0000000..36fe8cc
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *
+ */
+
+%include{
+
+#include <memory>
+#include <numeric>
+#include <algorithm>
+#include <utility>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <cstdlib>
+
+#include <vector>
+#include <list>
+#include <map>
+#include <stack>
+
+#include <antcc/config.h>
+#include <os/path.h>
+#include <os/file.h>
+#include <logger.h>
+#include <location.h>
+#include <xml/parser/ant_elements.h>
+#include <xml/parser/ant_element_factory.h>
+#include <project.h>
+#include <projectComponent.h>
+#include <reference_parser.h>
+
+#include <tasks/condition/ICondition.h>
+#include <tasks/condition/not.h>
+#include <tasks/condition/or.h>
+#include <tasks/condition/and.h>
+#include <tasks/condition/isSet.h>
+
+
+#include <reference_parser_base.h>
+}
+
+%stack_size 0
+
+%syntax_error {
+       printf("Syntax Error! Suggested tokens:\n");
+       const YYACTIONTYPE stateno = 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) {
+                       printf("  %s\n", yyTokenName[i]);
+               }
+       }
+}
+
+%code {
+#if 0
+std::unique_ptr<reference_parser> reference_parser::create() {
+               return std::make_unique<yypParser>();
+       }
+
+#endif
+}
+
+
+%token_type {Token &&}
+%type function { antcc::condition::ICondition }
+%type phrase   { antcc:condition::ICondition::Result *}
+
+
+value ::= . /* empty */ 
+    
+value ::= phrase(F). {
+        p->setResult(*F);
+        delete F;
+    }
+
+value ::= function(F).  {
+        antcc::condition::ICondition::Result _result;
+        if ( F&& F->eval(_result) )
+        {
+            std::cout<<"TODO function yes:"<<_result.m_Str<<std::endl;
+        } else {
+            std::cout<<"TODO function no:"<<_result.m_Str<<std::endl;
+
+        }
+        p->setResult("");
+    }
+
+
diff --git a/src/properties/reference_lexer.ragel b/src/properties/reference_lexer.ragel
new file mode 100644 (file)
index 0000000..558300d
--- /dev/null
@@ -0,0 +1,12 @@
+
+
+%%{
+
+    machine reference_lexer;
+
+}%%
+
+#include <string>
+#include <cstring>
+#include <stdlib.h>
+#include <numeric>
diff --git a/src/properties/reference_parser_base.h b/src/properties/reference_parser_base.h
new file mode 100644 (file)
index 0000000..4c00301
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __REFERERENCE_PAESER_BASE_H__
+#define __REFERERENCE_PAESER_BASE_H__
+
+#include <cstdio>
+#include <memory>
+#include <string>
+
+struct Token {
+
+       Token() = default;
+       Token(const Token &) = default;
+       Token(Token &&) = default;
+
+       Token(int i) : intValue(i)
+       {}
+       Token(const std::string &s) : stringValue(s)
+       {}
+       Token(std::string &&s) : stringValue(std::move(s))
+       {}
+
+
+       Token& operator=(const Token &) = default;
+       Token& operator=(Token &&) = default;
+
+       int intValue = 0;
+       std::string stringValue;
+};
+
+#endif
index cc1160a68b6efcdc889687215d7e8c19559e636f..8b9042b6b1751b88840b118d2114b49729a23dd3 100644 (file)
@@ -1,5 +1,5 @@
 PROJECT(antxml)
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.5)
 
 INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}")
 SUBDIRS(parser reqif)
diff --git a/utils b/utils
index 5f6e9134ab67b61537fc0bf557842221001f76b1..00ae10fbac5ef65798350fdbc1301c831abf28df 160000 (submodule)
--- a/utils
+++ b/utils
@@ -1 +1 @@
-Subproject commit 5f6e9134ab67b61537fc0bf557842221001f76b1
+Subproject commit 00ae10fbac5ef65798350fdbc1301c831abf28df