From f28b81ab872d6319bc24c534a484279a29e35a86 Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Wed, 16 Apr 2025 20:00:28 +0100 Subject: [PATCH] Started adding Parser --- .gitignore | 4 + LX-Compiler.sln | 17 +++++ LX-LLVM.vcxproj | 6 +- LX-LLVM.vcxproj.filters | 6 ++ Main.cpp | 1 + Parser/Parser.vcxproj | 139 ++++++++++++++++++++++++++++++++++ Parser/Parser.vcxproj.filters | 18 +++++ Parser/src/Parser.cpp | 9 +++ common/LLVM.h | 25 ++++++ common/Parser.h | 21 +++++ 10 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 Parser/Parser.vcxproj create mode 100644 Parser/Parser.vcxproj.filters create mode 100644 Parser/src/Parser.cpp create mode 100644 common/LLVM.h create mode 100644 common/Parser.h diff --git a/.gitignore b/.gitignore index 1066d77..c78a008 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ x64/ .vs/ + +# Ignore user-specific files # + +*.user diff --git a/LX-Compiler.sln b/LX-Compiler.sln index e1b0f26..f51b97d 100644 --- a/LX-Compiler.sln +++ b/LX-Compiler.sln @@ -6,10 +6,15 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LX-Compiler", "LX-LLVM.vcxproj", "{CC37E36F-B3B3-41B0-A887-01E8EFE84994}" ProjectSection(ProjectDependencies) = postProject {4E4019F5-12E0-4EE2-9658-A0DD3038EEDA} = {4E4019F5-12E0-4EE2-9658-A0DD3038EEDA} + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64} = {D6EAFB31-4AFD-4989-9522-D6609AC4ED64} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lexer", "Lexer\Lexer.vcxproj", "{4E4019F5-12E0-4EE2-9658-A0DD3038EEDA}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frontend-Modules", "Frontend-Modules", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Parser", "Parser\Parser.vcxproj", "{D6EAFB31-4AFD-4989-9522-D6609AC4ED64}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -34,10 +39,22 @@ Global {4E4019F5-12E0-4EE2-9658-A0DD3038EEDA}.Release|x64.Build.0 = Release|x64 {4E4019F5-12E0-4EE2-9658-A0DD3038EEDA}.Release|x86.ActiveCfg = Release|Win32 {4E4019F5-12E0-4EE2-9658-A0DD3038EEDA}.Release|x86.Build.0 = Release|Win32 + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64}.Debug|x64.ActiveCfg = Debug|x64 + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64}.Debug|x64.Build.0 = Debug|x64 + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64}.Debug|x86.ActiveCfg = Debug|Win32 + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64}.Debug|x86.Build.0 = Debug|Win32 + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64}.Release|x64.ActiveCfg = Release|x64 + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64}.Release|x64.Build.0 = Release|x64 + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64}.Release|x86.ActiveCfg = Release|Win32 + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {4E4019F5-12E0-4EE2-9658-A0DD3038EEDA} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {D6EAFB31-4AFD-4989-9522-D6609AC4ED64} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {411AFEC9-4075-4FCC-B95A-9288BC822E90} EndGlobalSection diff --git a/LX-LLVM.vcxproj b/LX-LLVM.vcxproj index 44d9d5f..68cec45 100644 --- a/LX-LLVM.vcxproj +++ b/LX-LLVM.vcxproj @@ -111,7 +111,7 @@ Console true - Lexer.lib;%(AdditionalDependencies) + Lexer.lib;Parser.lib;Ws2_32.lib;%(AdditionalDependencies) $(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) @@ -131,7 +131,7 @@ true true true - Lexer.lib;%(AdditionalDependencies) + Lexer.lib;Parser.lib;Ws2_32.lib;%(AdditionalDependencies) $(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) @@ -139,6 +139,8 @@ + + diff --git a/LX-LLVM.vcxproj.filters b/LX-LLVM.vcxproj.filters index 4066ea5..db15802 100644 --- a/LX-LLVM.vcxproj.filters +++ b/LX-LLVM.vcxproj.filters @@ -13,6 +13,12 @@ Common + + Common + + + Common + diff --git a/Main.cpp b/Main.cpp index 8ac84dc..375c842 100644 --- a/Main.cpp +++ b/Main.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include diff --git a/Parser/Parser.vcxproj b/Parser/Parser.vcxproj new file mode 100644 index 0000000..e594b2a --- /dev/null +++ b/Parser/Parser.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {d6eafb31-4afd-4989-9522-d6609ac4ed64} + Parser + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)inc;$(SolutionDir)common;%(AdditionalIncludeDirectories) + stdcpp20 + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)inc;$(SolutionDir)common;%(AdditionalIncludeDirectories) + stdcpp20 + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Parser/Parser.vcxproj.filters b/Parser/Parser.vcxproj.filters new file mode 100644 index 0000000..23540ae --- /dev/null +++ b/Parser/Parser.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + + + Source Files + + + \ No newline at end of file diff --git a/Parser/src/Parser.cpp b/Parser/src/Parser.cpp new file mode 100644 index 0000000..bfe8819 --- /dev/null +++ b/Parser/src/Parser.cpp @@ -0,0 +1,9 @@ +#include + +namespace LX +{ + std::vector> TurnTokensIntoAbstractSyntaxTree(std::vector& tokens, std::ofstream* log) + { + return std::vector>(); + } +} diff --git a/common/LLVM.h b/common/LLVM.h new file mode 100644 index 0000000..6999738 --- /dev/null +++ b/common/LLVM.h @@ -0,0 +1,25 @@ +#pragma once + +// Helper file for including all neccesarry parts of LLVM // +#ifdef _MSC_VER + + // Disables all warnings as LLVM files have a lot of Data-loss casts that won't cause issues // + #pragma warning(push) + #pragma warning(disable : 4244) + #pragma warning(disable : 4267) + #pragma warning(disable : 4624) + #pragma warning(disable : 4800) + + // Includes the LLVM files // + + #include + #include + #include + #include + + // Re-enables all warnings // + #pragma warning(pop) + +#else + #error This code only works with MSVC / VS22 +#endif // _MSC_VER diff --git a/common/Parser.h b/common/Parser.h new file mode 100644 index 0000000..11c846f --- /dev/null +++ b/common/Parser.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +#include +#include +#include + +namespace LX +{ + struct GlobalDeclaration + { + }; + + struct FunctionDeclaration + { + }; + + std::vector> TurnTokensIntoAbstractSyntaxTree(std::vector& tokens, std::ofstream* log); +}