summaryrefslogtreecommitdiffhomepage
path: root/src/CompilerKit/AST.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-05 11:49:28 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-05 11:50:39 -0500
commit037ac38824623c13070384e8fc0e70c4770dcdbd (patch)
tree19d7286c5d226b33f10743c76436dace0cf42112 /src/CompilerKit/AST.h
parent5535f22998bf991eeb75a56c9e147f0fd4bd23b2 (diff)
chore! new project filesystem structure.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/CompilerKit/AST.h')
-rw-r--r--src/CompilerKit/AST.h143
1 files changed, 0 insertions, 143 deletions
diff --git a/src/CompilerKit/AST.h b/src/CompilerKit/AST.h
deleted file mode 100644
index 3987f13..0000000
--- a/src/CompilerKit/AST.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* ========================================
-
- Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license
-
-======================================== */
-
-#pragma once
-
-#include <CompilerKit/CodeGenerator.h>
-#include <vector>
-
-#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 {
- kKeywordKindReserved = 0,
- kKeywordKindNamespace = 100,
- 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,
- kKeywordKindCount = kKeywordKindPtr - kKeywordKindNamespace + 1,
-};
-
-/// =========================================================== ///
-/// \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();
-
- /// =========================================================== ///
- /// @brief Checks if language is a valid frontend.
- /// =========================================================== ///
- virtual bool IsValid();
-};
-} // namespace CompilerKit
-
-#include <CompilerKit/AST.inl> \ No newline at end of file