Added data contents of AST types
This commit is contained in:
79
ast/inc/NodeTypes.h
Normal file
79
ast/inc/NodeTypes.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#include <LXC.h>
|
||||
|
||||
#include <NodeBase.h>
|
||||
|
||||
namespace LXC::AST
|
||||
{
|
||||
typedef std::string Identifier;
|
||||
|
||||
class FunctionCall final : public NodeValue
|
||||
{
|
||||
private:
|
||||
// The name of the function //
|
||||
Identifier m_FuncName;
|
||||
|
||||
// The arguments of the function //
|
||||
std::vector<std::unique_ptr<Node>> m_Arguments;
|
||||
};
|
||||
|
||||
class IntLiteral final : public NodeValue
|
||||
{
|
||||
private:
|
||||
// Yes numbers are stored as strings //
|
||||
std::string m_NumberValue;
|
||||
};
|
||||
|
||||
class Operation final : public NodeValue
|
||||
{
|
||||
private:
|
||||
// The sides of the operation //
|
||||
std::unique_ptr<Node> m_Lhs, m_Rhs;
|
||||
|
||||
// The operand of the operation //
|
||||
Lexer::Token::TokenType m_Operand;
|
||||
};
|
||||
|
||||
class VarDeclaration final : public Node
|
||||
{
|
||||
private:
|
||||
// The name of the variable //
|
||||
Identifier m_Name;
|
||||
|
||||
// Default value of the variable (nullable) //
|
||||
std::unique_ptr<VarAssignment> m_Value;
|
||||
};
|
||||
|
||||
class VarAssignment final : public Node
|
||||
{
|
||||
private:
|
||||
// The name of the variable //
|
||||
Identifier m_Name;
|
||||
|
||||
// Value to assign to the variable //
|
||||
std::unique_ptr<NodeValue> m_Value;
|
||||
};
|
||||
|
||||
class VarAccess final : public NodeValue
|
||||
{
|
||||
private:
|
||||
// The name of the variable //
|
||||
Identifier m_Name;
|
||||
};
|
||||
|
||||
class IfBranch final : public Node
|
||||
{
|
||||
private:
|
||||
// The condition of the branch //
|
||||
std::unique_ptr<Node> m_Condition;
|
||||
|
||||
// The body of the if-statement //
|
||||
std::vector<std::unique_ptr<Node>> m_Body;
|
||||
};
|
||||
|
||||
class ReturnStatement final : public Node
|
||||
{
|
||||
private:
|
||||
// The value to return (nullable) //
|
||||
std::unique_ptr<NodeValue> m_ReturnValue;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user