From: andre ebersold Date: Thu, 13 Jun 2024 13:02:10 +0000 (+0200) Subject: Started windows build with ragel and lemon X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=bfe15973500ce138e34cb35ae086348cf1bbbf06;p=antcc.git Started windows build with ragel and lemon --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 60a62b3..e387ce7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 aeca878..bd52bb8 160000 --- a/rules +++ b/rules @@ -1 +1 @@ -Subproject commit aeca878a84169490996e427211493ac306f00c7c +Subproject commit bd52bb81d0b9b6d93a31d3d78801798e13d05a8a diff --git a/src/properties/CMakeLists.txt b/src/properties/CMakeLists.txt index cf7226f..9c229fa 100644 --- a/src/properties/CMakeLists.txt +++ b/src/properties/CMakeLists.txt @@ -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 index 0000000..36fe8cc --- /dev/null +++ b/src/properties/reference.lemon @@ -0,0 +1,90 @@ +/* + * + */ + +%include{ + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +#include +} + +%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::create() { + return std::make_unique(); + } + +#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<setResult(""); + } + + diff --git a/src/properties/reference_lexer.ragel b/src/properties/reference_lexer.ragel new file mode 100644 index 0000000..558300d --- /dev/null +++ b/src/properties/reference_lexer.ragel @@ -0,0 +1,12 @@ + + +%%{ + + machine reference_lexer; + +}%% + +#include +#include +#include +#include diff --git a/src/properties/reference_parser_base.h b/src/properties/reference_parser_base.h new file mode 100644 index 0000000..4c00301 --- /dev/null +++ b/src/properties/reference_parser_base.h @@ -0,0 +1,29 @@ +#ifndef __REFERERENCE_PAESER_BASE_H__ +#define __REFERERENCE_PAESER_BASE_H__ + +#include +#include +#include + +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 diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index cc1160a..8b9042b 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -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 5f6e913..00ae10f 160000 --- a/utils +++ b/utils @@ -1 +1 @@ -Subproject commit 5f6e9134ab67b61537fc0bf557842221001f76b1 +Subproject commit 00ae10fbac5ef65798350fdbc1301c831abf28df