diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b3825c7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: + - "**" + - "!main" + pull_request: + branches: + - "**" + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y wget lsb-release software-properties-common gnupg catch2 + + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 22 + + echo "LLVM_DIR=/usr/lib/llvm-22/lib/cmake/llvm" >> $GITHUB_ENV + + - name: Build and Test + run: | + cmake . + make + ./bin/tests diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..64c1a57 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 3.31.6) + +project(alpha) + + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +include_directories(${CMAKE_SOURCE_DIR}/src) + +find_package(LLVM REQUIRED CONFIG) + +add_definitions(${LLVM_DEFINITIONS}) +llvm_map_components_to_libnames(llvm_libs + core + support + irreader + codegen + asmprinter + target + native + TargetParser +) + + +file(GLOB_RECURSE ALL_SRC_CPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") +list(FILTER ALL_SRC_CPP EXCLUDE REGEX ".*main\\.cpp$") + +file(GLOB_RECURSE ALL_SRC_HPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp") + +add_library(alpha_lib STATIC ${ALL_SRC_CPP} ${ALL_SRC_HPP}) + +target_include_directories(alpha_lib PUBLIC + ${CMAKE_SOURCE_DIR}/src + ${LLVM_INCLUDE_DIRS} +) +target_link_libraries(alpha_lib PUBLIC ${llvm_libs}) + +# Main compiler + +add_executable(main src/main.cpp) + +target_link_libraries(main PRIVATE alpha_lib) + +set_target_properties(main PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin +) + +# Tests +find_package(Catch2 3 REQUIRED) + +enable_testing() +file(GLOB_RECURSE ALL_TEST_CPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp") + + +add_executable(tests + ${ALL_TEST_CPP} +) + +target_link_libraries(tests PRIVATE + alpha_lib + Catch2::Catch2WithMain +) + +get_target_property(Catch2_INCLUDE_DIR Catch2::Catch2 INTERFACE_INCLUDE_DIRECTORIES) +target_include_directories(tests PRIVATE ${Catch2_INCLUDE_DIR}) + +include(Catch) +catch_discover_tests(tests) + +set_target_properties(tests PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin +) \ No newline at end of file diff --git a/src/syntax_analyser/statement/addition/addition.hpp b/src/syntax_analyser/statement/addition/addition.hpp index e94c873..ef2bcf7 100644 --- a/src/syntax_analyser/statement/addition/addition.hpp +++ b/src/syntax_analyser/statement/addition/addition.hpp @@ -1,4 +1,5 @@ #pragma once +#include #include "syntax_analyser/statement/statement.hpp" #include "syntax_analyser/statement/value/identifier/identifier.hpp" diff --git a/src/syntax_analyser/statement/print/print.hpp b/src/syntax_analyser/statement/print/print.hpp index 77944b0..6478fcc 100644 --- a/src/syntax_analyser/statement/print/print.hpp +++ b/src/syntax_analyser/statement/print/print.hpp @@ -1,8 +1,8 @@ #pragma once +#include -#include "syntax_analyser/statement/assignment/assignment_type.hpp" #include "syntax_analyser/statement/statement.hpp" -#include "syntax_analyser/statement/value/identifier/identifier.hpp" +#include "syntax_analyser/statement/value/value.hpp" class PrintStatement : public Statement { public: