Added AST constructors
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#include <LXC.h>
|
||||
|
||||
#include <NodeTypes.h>
|
||||
|
||||
namespace LXC::AST
|
||||
{
|
||||
FunctionCall::FunctionCall (Identifier& functionName, std::vector<std::unique_ptr<NodeValue>>& arguments)
|
||||
: NodeValue(NodeType::FunctionCall), m_FuncName(std::move(functionName)), m_Arguments(std::move(arguments))
|
||||
{}
|
||||
|
||||
IntLiteral::IntLiteral(std::string& value)
|
||||
: NodeValue(NodeType::IntLiteral), m_NumberValue(std::move(value))
|
||||
{}
|
||||
|
||||
Operation::Operation(std::unique_ptr<NodeValue>& left, Lexer::Token::TokenType operand, std::unique_ptr<NodeValue>& right)
|
||||
: NodeValue(NodeType::Operation), m_Lhs(std::move(left)), m_Operand(operand), m_Rhs(std::move(right))
|
||||
{}
|
||||
|
||||
VarDeclaration::VarDeclaration(Identifier& name)
|
||||
: Node(NodeType::Var_Declare), m_Name(std::move(name)), m_Value(nullptr)
|
||||
{}
|
||||
|
||||
VarDeclaration::VarDeclaration(Identifier& name, std::unique_ptr<VarAssignment>& value)
|
||||
: Node(NodeType::Var_Declare), m_Name(std::move(name)), m_Value(std::move(value))
|
||||
{}
|
||||
|
||||
VarAssignment::VarAssignment(Identifier& name, std::unique_ptr<NodeValue>& value)
|
||||
: Node(NodeType::Var_Assign), m_Value(std::move(value))
|
||||
{}
|
||||
|
||||
VarAccess::VarAccess(Identifier& name)
|
||||
: NodeValue(NodeType::Var_Access), m_Name(std::move(m_Name))
|
||||
{}
|
||||
|
||||
IfBranch::IfBranch(std::unique_ptr<NodeValue>& condition, std::vector<std::unique_ptr<Node>>& body)
|
||||
: Node(NodeType::IfBranch), m_Condition(std::move(condition)), m_Body(std::move(body))
|
||||
{}
|
||||
|
||||
ReturnStatement::ReturnStatement(std::unique_ptr<NodeValue>& value)
|
||||
: Node(NodeType::ReturnVal), m_ReturnValue(std::move(m_ReturnValue))
|
||||
{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user