106 lines
2.5 KiB
C++
106 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include <Util.h>
|
|
|
|
#include <NodeBase.h>
|
|
#include <Token.h>
|
|
|
|
namespace PashaBibko::LXC::AST
|
|
{
|
|
class FunctionCall final : public NodeValue
|
|
{
|
|
public:
|
|
FunctionCall(const Identifier& functionName, ValueList& arguments);
|
|
|
|
private:
|
|
// The name of the function //
|
|
Identifier m_FuncName;
|
|
|
|
// The arguments of the function //
|
|
ValueList m_Arguments;
|
|
};
|
|
|
|
class IntLiteral final : public NodeValue
|
|
{
|
|
public:
|
|
IntLiteral(const std::string_view& value);
|
|
|
|
private:
|
|
// Yes numbers are stored as strings //
|
|
std::string m_NumberValue;
|
|
};
|
|
|
|
class Operation final : public NodeValue
|
|
{
|
|
public:
|
|
Operation(NodeValuePtr& left, Lexer::Token::TokenType operand, NodeValuePtr& right);
|
|
|
|
private:
|
|
// The sides of the operation //
|
|
NodeValuePtr m_Lhs, m_Rhs;
|
|
|
|
// The operand of the operation //
|
|
Lexer::Token::TokenType m_Operand;
|
|
};
|
|
|
|
class VarDeclaration final : public Node
|
|
{
|
|
public:
|
|
VarDeclaration(Identifier& name);
|
|
VarDeclaration(Identifier& name, NodeValuePtr& value);
|
|
|
|
private:
|
|
// The name of the variable //
|
|
Identifier m_Name;
|
|
|
|
// Default value of the variable (nullable) //
|
|
NodeValuePtr m_Value;
|
|
};
|
|
|
|
class VarAssignment final : public Node
|
|
{
|
|
public:
|
|
VarAssignment(Identifier& name, NodeValuePtr& value);
|
|
|
|
private:
|
|
// The name of the variable //
|
|
Identifier m_Name;
|
|
|
|
// Value to assign to the variable //
|
|
NodeValuePtr m_Value;
|
|
};
|
|
|
|
class VarAccess final : public NodeValue
|
|
{
|
|
public:
|
|
VarAccess(const Identifier& name);
|
|
|
|
private:
|
|
// The name of the variable //
|
|
Identifier m_Name;
|
|
};
|
|
|
|
class IfBranch final : public Node
|
|
{
|
|
public:
|
|
IfBranch(NodeValuePtr& condition, SyntaxBranch& body);
|
|
|
|
private:
|
|
// The condition of the branch //
|
|
NodeValuePtr m_Condition;
|
|
|
|
// The body of the if-statement //
|
|
SyntaxBranch m_Body;
|
|
};
|
|
|
|
class ReturnStatement final : public Node
|
|
{
|
|
public:
|
|
ReturnStatement(NodeValuePtr& value);
|
|
|
|
private:
|
|
// The value to return (nullable) //
|
|
NodeValuePtr m_ReturnValue;
|
|
};
|
|
}
|