Files
LXC/parser/inc/LX_Parser.h
Pasha Bibko 7b445ed382 Renamed Parser.h -> LX_Parser.h
Was causing issues with intelisense in VSC due to a Windows.h file named Parser.h having priority
2025-08-19 15:23:27 +01:00

48 lines
1.1 KiB
C++

#pragma once
#include <Util.h>
#include <NodeTypes.h>
#include <Lexer.h>
namespace PashaBibko::LXC::Parser
{
struct ParserError {};
struct FunctionAST
{
FunctionAST() :
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))
{}
std::string name;
std::vector<std::pair<std::string, std::string>> funcParams;
AST::SyntaxBranch contents;
std::string LogStr() const
{
std::ostringstream os;
os << name << " (";
for (size_t i = 0; i < funcParams.size(); i++)
{
os << funcParams[i].first << ' ' << funcParams[i].second;
if (i != funcParams.size() - 1)
os << ", ";
}
os << ")";
return os.str();
}
};
Util::ReturnVal<std::vector<FunctionAST>, ParserError> TurnTokensIntoAST(const Lexer::LexerOutput& input);
}