Moved Common to external git repo

Also changed namespace from LXC to PashaBibko::LXC
This commit is contained in:
Pasha Bibko
2025-08-09 21:31:36 +01:00
parent 3c638fa92b
commit a54c0ccbab
26 changed files with 135 additions and 632 deletions

View File

@@ -1,7 +1,7 @@
# Fetches all .cpp files for the binary #
add_library(Parser STATIC
src/Parser.cpp
"inc/Parser.h")
)
# Adds the headers in the current directory #
target_include_directories (
@@ -9,10 +9,11 @@ target_include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/inc
)
# Links to the Lexer and AST so it can use their data types #
target_link_libraries(Parser PUBLIC Lexer)
target_link_libraries(Parser PUBLIC AST)
# Links to the all needed internal libraries #
target_link_libraries(Parser PRIVATE PashaBibko-UTIL)
target_link_libraries(Parser PRIVATE Lexer)
target_link_libraries(Parser PRIVATE AST)
# Creates the precompiled header of the binary #
target_include_directories(Parser PRIVATE ${CMAKE_SOURCE_DIR}/common)
target_precompile_headers(Parser PRIVATE ${CMAKE_SOURCE_DIR}/common/LXC.h)
target_include_directories(Parser PRIVATE ${CMAKE_SOURCE_DIR}/external/util)
target_precompile_headers(Parser PRIVATE ${CMAKE_SOURCE_DIR}/external/util/Util.h)

View File

@@ -1,11 +1,11 @@
#pragma once
#include <LXC.h>
#include <Util.h>
#include <NodeTypes.h>
#include <Lexer.h>
namespace LXC::Parser
namespace PashaBibko::LXC::Parser
{
struct ParserError {};
@@ -15,6 +15,8 @@ namespace LXC::Parser
name{}, contents{}, funcParams{}
{}
FunctionAST(const FunctionAST& other) = delete;
FunctionAST(FunctionAST&& other) noexcept :
name(std::move(other.name)), contents(std::move(other.contents)), funcParams(std::move(other.funcParams))
{}

View File

@@ -1,25 +1,25 @@
#include <LXC.h>
#include <Util.h>
#include <Parser.h>
namespace LXC::Internal
namespace PashaBibko::LXC::Internal
{
template<typename NodeType, typename... Args>
requires std::is_base_of_v<AST::Node, NodeType> && std::is_constructible_v<NodeType, Args...>
static const inline Util::ReturnVal<AST::NodePtr, Parser::ParserError> CreateNode(Args&&... args)
{
return Util::ReturnVal<AST::NodePtr, Parser::ParserError>(std::make_unique<NodeType>(std::forward<Args>(args)...));
return AST::NodePtr(std::make_unique<NodeType>(std::forward<Args>(args)...));
}
template<typename NodeType, typename... Args>
requires std::is_base_of_v<AST::NodeValue, NodeType> && std::is_constructible_v<NodeType, Args...>
static const inline Util::ReturnVal<AST::NodeValuePtr, Parser::ParserError> CreateNodeV(Args&&... args)
{
return Util::ReturnVal<AST::NodeValuePtr, Parser::ParserError>(std::make_unique<NodeType>(std::forward<Args>(args)...));
return AST::NodeValuePtr(std::make_unique<NodeType>(std::forward<Args>(args)...));
}
}
namespace LXC::Parser
namespace PashaBibko::LXC::Parser
{
class ParserContext final
{
@@ -130,7 +130,7 @@ namespace LXC::Parser
ctx.Advance();
// Adds the current argument to the ValueList //
arguments.push_back(ParsePrimary(ctx));
arguments.push_back(std::move(ParsePrimary(ctx).Result()));
}
}