From 317e9f3b6bdba0d7f23ecec04a25ddd6309df5b5 Mon Sep 17 00:00:00 2001 From: LaEntropiaa Date: Sat, 28 Feb 2026 13:59:02 -0600 Subject: [PATCH] Jut setting all up for the calculator --- .gitignore | 54 +++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 36 ++++++++++++++++++++++++++++++ include/ast.h | 0 include/evaluator.h | 0 include/lexer.h | 0 include/parser.h | 0 src/ast.c | 0 src/evaluator.c | 0 src/lexer.c | 0 src/main.c | 7 ++++++ src/parser.c | 0 test/CMakeLists.txt | 10 +++++++++ test/test_parser.c | 5 +++++ 13 files changed, 112 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 include/ast.h create mode 100644 include/evaluator.h create mode 100644 include/lexer.h create mode 100644 include/parser.h create mode 100644 src/ast.c create mode 100644 src/evaluator.c create mode 100644 src/lexer.c create mode 100644 src/main.c create mode 100644 src/parser.c create mode 100644 test/CMakeLists.txt create mode 100644 test/test_parser.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..157dd82 --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +# Directories +build/ +build-*/ +cmake-build-*/ +.cache/ +out/ +out/Debug/ +out/Release/ + +# Cmake files +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +CTestTestfile.cmake +Testing/ +compile_commands.json +../compile_commands.json +build/compile_commands.json + +# Make / Ninja +Makefile +*.ninja +*.ninja_deps +*.ninja_log +rules.ninja + +# Object files +*.o +*.obj +*.lo +*.la + +# Binaries +*.out +*.exe +*.dll +*.so +*.so.* +*.dylib +*.a + +# Debug / Sanitizer +*.dSYM/ +*.gcno +*.gcda +*.gcov + +# Editors +.vscode/ +.idea/ +*.swp +*.swo +*~ + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..be9fbf8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.20) +project(calculator VERSION 1.0 LANGUAGES C) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) + +# Export compile_commands.json (para clangd) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +add_compile_options( + -Wall + -Wextra + -Wpedantic +) + + +include_directories(include) + +add_library(calculator_lib + src/lexer.c + src/parser.c + src/ast.c + src/evaluator.c +) + +add_executable(calculator src/main.c) + +target_link_libraries(calculator calculator_lib) + +# ------------------------ +# Testing +# ------------------------ + +enable_testing() +add_subdirectory(test) + diff --git a/include/ast.h b/include/ast.h new file mode 100644 index 0000000..e69de29 diff --git a/include/evaluator.h b/include/evaluator.h new file mode 100644 index 0000000..e69de29 diff --git a/include/lexer.h b/include/lexer.h new file mode 100644 index 0000000..e69de29 diff --git a/include/parser.h b/include/parser.h new file mode 100644 index 0000000..e69de29 diff --git a/src/ast.c b/src/ast.c new file mode 100644 index 0000000..e69de29 diff --git a/src/evaluator.c b/src/evaluator.c new file mode 100644 index 0000000..e69de29 diff --git a/src/lexer.c b/src/lexer.c new file mode 100644 index 0000000..e69de29 diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..dba861c --- /dev/null +++ b/src/main.c @@ -0,0 +1,7 @@ +#include +#include + +int main(int argc, char *argv[]) { + puts("Hello"); + return EXIT_SUCCESS; +} diff --git a/src/parser.c b/src/parser.c new file mode 100644 index 0000000..e69de29 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..2e3cef2 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,10 @@ +find_package(cmocka REQUIRED) + +add_executable(test_parser test_parser.c) + +target_link_libraries(test_parser + calculator_lib + cmocka::cmocka +) + +add_test(NAME parser_tests COMMAND test_parser) diff --git a/test/test_parser.c b/test/test_parser.c new file mode 100644 index 0000000..8fe53f9 --- /dev/null +++ b/test/test_parser.c @@ -0,0 +1,5 @@ +#include + +int main() { + return EXIT_SUCCESS; +}