diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-27 23:02:19 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-27 23:02:19 +0200 |
| commit | 7878653e8dbd65d94ea8ea8bae6e0afd3c3d0af3 (patch) | |
| tree | 5f77d7f9d500efcafdcb4efb787ce71a5d5ec1ab /dev/LibCompiler/Frontend.h | |
| parent | d12204e7302b8f3bd521c782094338733abfded1 (diff) | |
fix: fix SEGFAULT on CxxDrv (AMD64), caused by a stack corruption.
refactor: Refactor LibCompiler's codebase, deperecate older C compilers,
and fully focusing on C++ now.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler/Frontend.h')
| -rw-r--r-- | dev/LibCompiler/Frontend.h | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/dev/LibCompiler/Frontend.h b/dev/LibCompiler/Frontend.h index 5f054ac..f39c9d4 100644 --- a/dev/LibCompiler/Frontend.h +++ b/dev/LibCompiler/Frontend.h @@ -8,34 +8,11 @@ #include <LibCompiler/CodeGen.h> -#define LC_COMPILER_FRONTEND : public LibCompiler::CompilerFrontendInterface +#define LC_COMPILER_FRONTEND : public ::LibCompiler::CompilerFrontendInterface namespace LibCompiler { inline static auto kInvalidFrontend = "?"; -/// @brief Compiler backend, implements a frontend, such as C, C++... -/// See Toolchain, for some examples. -class CompilerFrontendInterface { - public: - explicit CompilerFrontendInterface() = default; - virtual ~CompilerFrontendInterface() = default; - - LIBCOMPILER_COPY_DEFAULT(CompilerFrontendInterface); - - // NOTE: cast this to your user defined ast. - typedef void* AstType; - - //! @brief Compile a syntax tree ouf of the text. - //! Also takes the source file name for metadata. - - virtual bool Compile(std::string text, std::string file) = 0; - - //! @brief What language are we dealing with? - virtual const char* Language() { return kInvalidFrontend; } - - virtual bool IsValid() { return strcmp(this->Language(), kInvalidFrontend) > 0; } -}; - struct SyntaxLeafList; struct SyntaxLeafList; struct CompilerKeyword; @@ -81,7 +58,7 @@ enum KeywordKind { /// \brief Compiler keyword information struct. struct CompilerKeyword { - STLString keyword_name{""}; + STLString keyword_name{""}; KeywordKind keyword_kind{kKeywordKindInvalid}; }; @@ -118,4 +95,27 @@ BOOL find_word(std::string haystack, std::string needle) noexcept; /// \param needle /// \return position of needle. std::size_t find_word_range(std::string haystack, std::string 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; + + LIBCOMPILER_COPY_DEFAULT(CompilerFrontendInterface); + + // NOTE: cast this to your user defined ast. + typedef void* AstType; + + //! @brief Compile a syntax tree ouf of the text. + //! Also takes the source file name for metadata. + + virtual LibCompiler::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) = 0; + + //! @brief What language are we dealing with? + virtual const char* Language() { return kInvalidFrontend; } + + virtual bool IsValid() { return strcmp(this->Language(), kInvalidFrontend) > 0; } +}; } // namespace LibCompiler |
