Skip to content

Commit

Permalink
Added attributes, constructor, destructor, and to_string to variable …
Browse files Browse the repository at this point in the history
…declaration node
  • Loading branch information
hrszpuk committed Jan 6, 2025
1 parent 6e313e0 commit e61f35b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/dragon/ast/variable_declaration_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@
#include "../ast.h"

class VariableDeclarationNode : public StatementNode {
public:
Token identifier;
Token type;
std::unique_ptr<ExpressionNode> value;
bool is_const;

explicit VariableDeclarationNode(Token identifier, Token type, std::unique_ptr<ExpressionNode> value, bool is_const)
: identifier(std::move(identifier)), type(std::move(type)), value(std::move(value)), is_const(is_const) {}

~VariableDeclarationNode() override = default;

std::string to_string() const override {
return "VariableDeclarationNode(identifier: " + identifier.to_string()
+ ", type: " + type.to_string()
+ ", is_const: " + (is_const ? "true" : "false") + ")";
}
};

0 comments on commit e61f35b

Please sign in to comment.