Added parser project

This commit is contained in:
Pasha Bibko
2025-07-23 19:33:33 +01:00
parent 6a534ba635
commit 86a178b7d5
10 changed files with 93 additions and 30 deletions

18
parser/CMakeLists.txt Normal file
View File

@@ -0,0 +1,18 @@
# 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 (
Parser PUBLIC
${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)
# 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)

19
parser/inc/Parser.h Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include <LXC.h>
#include <NodeTypes.h>
#include <Lexer.h>
namespace LXC::Parser
{
struct ParserError {};
struct FunctionAST
{
std::string name;
AST::SyntaxBranch contents;
};
Util::ReturnVal<std::vector<FunctionAST>, ParserError> TurnTokensIntoAST(const Lexer::LexerOutput& input);
}

11
parser/src/Parser.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include <LXC.h>
#include <Parser.h>
namespace LXC::Parser
{
Util::ReturnVal<std::vector<FunctionAST>, ParserError> TurnTokensIntoAST(const Lexer::LexerOutput& input)
{
return Util::FunctionFail<ParserError>();
}
}