From 6a348bd8899d3c00f4ac13becef91872fcbe8072 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 14 Apr 2025 14:33:11 +0200 Subject: cxxdrv: Add whitespace cleanup and initial support for class/struct parsing --- dev/LibCompiler/src/AssemblyFactory.cc | 4 ++-- dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'dev/LibCompiler/src') diff --git a/dev/LibCompiler/src/AssemblyFactory.cc b/dev/LibCompiler/src/AssemblyFactory.cc index 3853446..46ebed3 100644 --- a/dev/LibCompiler/src/AssemblyFactory.cc +++ b/dev/LibCompiler/src/AssemblyFactory.cc @@ -9,12 +9,12 @@ /** * @file AssemblyFactory.cxx - * @author amlal (amlal@zka.com) + * @author amlal (amlal@nekernel.org) * @brief Assembler Kit * @version 0.1 * @date 2024-01-27 * - * @copyright Copyright (c) 2024 Amlal El Mahrouss + * @copyright Copyright (c) 2024-2025 Amlal El Mahrouss * */ diff --git a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc index 62d1729..a184e45 100644 --- a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc +++ b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc @@ -230,7 +230,17 @@ Boolean CompilerFrontendCPlusPlus::Compile(std::string text, const std::string file) { if (text.empty()) - return false; + return true; + + // Clean whitespace and tabs + std::string cleanLine = text; + cleanLine.erase(std::remove(cleanLine.begin(), cleanLine.end(), '\t'), cleanLine.end()); + cleanLine.erase(0, cleanLine.find_first_not_of(" \r\n")); + cleanLine.erase(cleanLine.find_last_not_of(" \r\n") + 1); + + // Skip empty, doc, or block comment lines + if (cleanLine.empty() || cleanLine.starts_with("///") || cleanLine.starts_with("//") || cleanLine.starts_with("/*")) + return true; std::size_t index = 0UL; std::vector> keywords_list; @@ -983,7 +993,7 @@ static void cxx_print_help() { kSplashCxx(); kPrintF("%s", "No help available, see:\n"); - kPrintF("%s", "www.zws.zka.com/help/c++lang\n"); + kPrintF("%s", "nekernel.org/docs/cxxdrv\n"); } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3