summaryrefslogtreecommitdiffhomepage
path: root/dev/CompilerKit/Frontend.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:05:29 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:05:29 +0100
commitbbe2c77243c541ca7e0075149f5be3262eb89523 (patch)
treeae5d59d299344fd19584a2c3642bacd788e841d4 /dev/CompilerKit/Frontend.h
parentb5adf16a96b9cbb80c74cf30404ed5bcff03ac34 (diff)
feat! breaking changes on necti sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/CompilerKit/Frontend.h')
-rw-r--r--dev/CompilerKit/Frontend.h138
1 files changed, 0 insertions, 138 deletions
diff --git a/dev/CompilerKit/Frontend.h b/dev/CompilerKit/Frontend.h
deleted file mode 100644
index df70048..0000000
--- a/dev/CompilerKit/Frontend.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* ========================================
-
- Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license
-
-======================================== */
-
-#pragma once
-
-#include <CompilerKit/Compiler.h>
-
-#define CK_COMPILER_FRONTEND : public ::CompilerKit::CompilerFrontendInterface
-
-namespace CompilerKit {
-inline static auto kInvalidFrontend = "(null)";
-
-struct SyntaxLeafList;
-struct SyntaxLeafList;
-struct CompilerKeyword;
-
-/// =========================================================== ///
-/// @note we want to do that to separate keywords.
-/// =========================================================== ///
-
-enum KeywordKind {
- kKeywordKindNamespace,
- kKeywordKindFunctionStart,
- kKeywordKindFunctionEnd,
- kKeywordKindVariable,
- kKeywordKindVariablePtr,
- kKeywordKindType,
- kKeywordKindTypePtr,
- kKeywordKindExpressionBegin,
- kKeywordKindExpressionEnd,
- kKeywordKindArgSeparator,
- kKeywordKindBodyStart,
- kKeywordKindBodyEnd,
- kKeywordKindClass,
- kKeywordKindPtrAccess,
- kKeywordKindAccess,
- kKeywordKindIf,
- kKeywordKindElse,
- kKeywordKindElseIf,
- kKeywordKindVariableAssign,
- kKeywordKindVariableDec,
- kKeywordKindVariableInc,
- kKeywordKindConstant,
- kKeywordKindTypedef,
- kKeywordKindEndInstr,
- kKeywordKindSpecifier,
- kKeywordKindInvalid,
- kKeywordKindReturn,
- kKeywordKindCommentInline,
- kKeywordKindCommentMultiLineStart,
- kKeywordKindCommentMultiLineEnd,
- kKeywordKindEq,
- kKeywordKindNotEq,
- kKeywordKindGreaterEq,
- kKeywordKindLessEq,
- kKeywordKindPtr,
-};
-
-/// =========================================================== ///
-/// \brief Compiler keyword information struct.
-/// =========================================================== ///
-struct CompilerKeyword {
- CompilerKeyword(STLString name, KeywordKind kind) : keyword_name(name), keyword_kind(kind) {}
-
- STLString keyword_name{""};
- KeywordKind keyword_kind{kKeywordKindInvalid};
-};
-
-struct SyntaxLeafList final {
- struct SyntaxLeaf final {
- Int32 fUserType{0U};
- CompilerKeyword fUserData{"", kKeywordKindInvalid};
-
- STLString fUserValue{""};
- struct SyntaxLeaf* fNext{nullptr};
- };
-
- std::vector<SyntaxLeaf> fLeafList;
- SizeType fNumLeafs{0};
-
- SizeType SizeOf() { return fNumLeafs; }
- std::vector<SyntaxLeaf>& Get() { return fLeafList; }
- SyntaxLeaf& At(SizeType index) { return fLeafList[index]; }
-};
-
-/// =========================================================== ///
-/// 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;
-
-/// =========================================================== ///
-/// 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;
-
-/// =========================================================== ///
-/// @brief Compiler backend, implements a frontend, such as C, C++...
-/// See Toolchain, for some examples.
-/// =========================================================== ///
-class CompilerFrontendInterface {
- public:
- explicit CompilerFrontendInterface() = default;
- virtual ~CompilerFrontendInterface() = default;
-
- NECTI_COPY_DEFAULT(CompilerFrontendInterface);
-
- /// =========================================================== ///
- // NOTE: cast this to your user defined ast.
- /// =========================================================== ///
- typedef VoidPtr AstType;
-
- /// =========================================================== ///
- //! @brief Compile a syntax tree ouf of the text.
- //! Also takes the source file name for metadata.
- /// =========================================================== ///
-
- virtual CompilerKit::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) = 0;
-
- /// =========================================================== ///
- //! @brief What language are we dealing with?
- /// =========================================================== ///
- virtual const char* Language() { return kInvalidFrontend; }
-
- /// =========================================================== ///
- /// @brief Checks if language is a valid frontend.
- /// =========================================================== ///
- virtual bool IsValid() { return strcmp(this->Language(), kInvalidFrontend) > 0; }
-};
-} // namespace CompilerKit