48 lines
1.2 KiB
C++
48 lines
1.2 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 << ") [" << contents.size() << ']';
|
|
return os.str();
|
|
}
|
|
};
|
|
|
|
Util::ReturnVal<std::vector<FunctionAST>, ParserError> TurnTokensIntoAST(const Lexer::LexerOutput& input);
|
|
}
|