diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:05:29 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:05:29 +0100 |
| commit | bbe2c77243c541ca7e0075149f5be3262eb89523 (patch) | |
| tree | ae5d59d299344fd19584a2c3642bacd788e841d4 /dev/CompilerKit/src/Frontend.cc | |
| parent | b5adf16a96b9cbb80c74cf30404ed5bcff03ac34 (diff) | |
feat! breaking changes on necti sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/CompilerKit/src/Frontend.cc')
| -rw-r--r-- | dev/CompilerKit/src/Frontend.cc | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/dev/CompilerKit/src/Frontend.cc b/dev/CompilerKit/src/Frontend.cc deleted file mode 100644 index baac34e..0000000 --- a/dev/CompilerKit/src/Frontend.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* ======================================== - - Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license - -======================================== */ - -#include <CompilerKit/Frontend.h> - -/** - * @file Frontend.cc - * @author Amlal El Mahrouss (amlal@nekernel.org) - * @brief Frontend API of NeCTI - * @version 0.0.2 - * - * @copyright Copyright (c) 2025 Amlal El Mahrouss and NeKernel.org Contributors - * - */ - -namespace CompilerKit { -/// find the perfect matching word in a haystack. -/// \param haystack base string -/// \param needle the string we search for. -/// \return if we found it or not. -Bool find_word(STLString haystack, STLString needle) noexcept { - auto index = haystack.find(needle); - - // check for needle validity. - if (index == STLString::npos) return false; - - // declare lambda - auto not_part_of_word = [&](int index) { - if (std::isspace(haystack[index]) || std::ispunct(haystack[index])) return true; - - if (index <= 0 || index >= haystack.size()) return true; - - return false; - }; - - return not_part_of_word(index - 1) && not_part_of_word(index + needle.size()); -} - -/// find a word within strict conditions and returns a range of it. -/// \param haystack -/// \param needle -/// \return position of needle. -SizeType find_word_range(STLString haystack, STLString needle) noexcept { - auto index = haystack.find(needle); - - // check for needle validity. - if (index == STLString::npos) return false; - - if (!isalnum((haystack[index + needle.size() + 1])) && - !isdigit(haystack[index + needle.size() + 1]) && - !isalnum((haystack[index - needle.size() - 1])) && - !isdigit(haystack[index - needle.size() - 1])) { - return index; - } - - return STLString::npos; -} -} // namespace CompilerKit
\ No newline at end of file |
