diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0eda0a7..2f78fb4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR}) +add_library(Lexesis-backends + backends/cpp.cpp + ) + add_executable(Lexesis main.cpp automata.cpp @@ -9,7 +13,7 @@ add_executable(Lexesis inputparser.cpp template.cpp ) -target_link_libraries(Lexesis mstch::mstch) +target_link_libraries(Lexesis Lexesis-backends mstch::mstch) install(TARGETS Lexesis RUNTIME DESTINATION bin diff --git a/src/backends/cpp.cpp b/src/backends/cpp.cpp index a149280..20092c3 100644 --- a/src/backends/cpp.cpp +++ b/src/backends/cpp.cpp @@ -39,7 +39,7 @@ namespace lxs { namespace backends { topLevel["trans_idx"] = transformTransitionIndices(transition_indices.first); topLevel["num_transitions_per_state"] = templ::make_string(std::to_string(transition_indices.second)); - topLevel["table"] = buildTable(dfa, transition_indices.first); + topLevel["table"] = buildTable(dfa, transition_indices.first, transition_indices.second); topLevel["token_types"] = buildTokenList(dfa); diff --git a/src/template.cpp b/src/template.cpp index ec60b18..e62cae9 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -12,17 +12,12 @@ namespace templ { return mstch::node(_string); } - TemplateContext make_map(std::map _map) { - // return mstch::node(_map); -> g++ goes mental.. - mstch::map result; - for(auto& item: _map) { - result[item.first] = item.second; - } - return result; + TemplateContext make_map(std::map _map) { + return mstch::map(_map); } TemplateContext make_array(std::vector _array) { - return mstch::node(_array); + return mstch::array(_array); }