From 586914df4ee65b8c01d9e8c5ec53134b69b41d76 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 6 Feb 2026 18:44:42 -0700 Subject: [PATCH] Sprint 2 Step 1: base ASTNode class and Module concept Adds the C++ editor stack foundation with ASTNode (id, conceptType, parent pointer, virtual dtor) and Module as the first concrete concept (name, targetLanguage). Header-only, compiles with C++20, test passes all assertions. Co-Authored-By: Claude Opus 4.6 --- editor/CMakeLists.txt | 8 ++++++++ editor/src/ast/ASTNode.h | 11 +++++++++++ editor/src/ast/Module.h | 15 +++++++++++++++ editor/tests/step1_test.cpp | 16 ++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 editor/CMakeLists.txt create mode 100644 editor/src/ast/ASTNode.h create mode 100644 editor/src/ast/Module.h create mode 100644 editor/tests/step1_test.cpp diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt new file mode 100644 index 0000000..30fddb7 --- /dev/null +++ b/editor/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.20) +project(WhetstoneEditor LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(step1_test tests/step1_test.cpp) +target_include_directories(step1_test PRIVATE src) diff --git a/editor/src/ast/ASTNode.h b/editor/src/ast/ASTNode.h new file mode 100644 index 0000000..2fd9bd1 --- /dev/null +++ b/editor/src/ast/ASTNode.h @@ -0,0 +1,11 @@ +#pragma once +#include + +class ASTNode { +public: + std::string id; + std::string conceptType; + ASTNode* parent = nullptr; + + virtual ~ASTNode() = default; +}; diff --git a/editor/src/ast/Module.h b/editor/src/ast/Module.h new file mode 100644 index 0000000..73d1e0a --- /dev/null +++ b/editor/src/ast/Module.h @@ -0,0 +1,15 @@ +#pragma once +#include "ASTNode.h" + +class Module : public ASTNode { +public: + std::string name; + std::string targetLanguage; + + Module() { conceptType = "Module"; } + Module(const std::string& id, const std::string& name, const std::string& lang) + : name(name), targetLanguage(lang) { + this->id = id; + this->conceptType = "Module"; + } +}; diff --git a/editor/tests/step1_test.cpp b/editor/tests/step1_test.cpp new file mode 100644 index 0000000..d764544 --- /dev/null +++ b/editor/tests/step1_test.cpp @@ -0,0 +1,16 @@ +#include "../src/ast/Module.h" +#include +#include + +int main() { + Module m("SFE_M001", "SimpleFunctionExample", "python"); + + assert(m.id == "SFE_M001"); + assert(m.name == "SimpleFunctionExample"); + assert(m.targetLanguage == "python"); + assert(m.conceptType == "Module"); + assert(m.parent == nullptr); + + std::cout << "Step 1: PASS" << std::endl; + return 0; +}