Skip to content

Commit 3a97228

Browse files
feat: implement AST node constructors for FunctionDeclaration and BlockStatement
1 parent 72c4559 commit 3a97228

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

wheel_parser/nodes.cxx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <vector>
2+
#include "wheel_parser/ast/nodes.hxx"
3+
4+
using std::move;
5+
using wheel_parser::ast::Node;
6+
using wheel_parser::ast::StatementNode;
7+
using wheel_parser::ast::FunctionDeclaration;
8+
using wheel_parser::ast::BlockStatement;
9+
using wheel_parser::ast::NodeKind;
10+
11+
Node::Node(NodeKind node_kind,
12+
const Token* token) noexcept : node_kind(node_kind), token(token) {}
13+
14+
StatementNode::StatementNode(NodeKind node_kind,
15+
const Token *token) noexcept : Node(node_kind, token) {}
16+
17+
FunctionDeclaration::FunctionDeclaration(const Token *token,
18+
SymbolID func_name,
19+
std::vector<SymbolID> func_params,
20+
StatementNode *func_body) noexcept :
21+
StatementNode(NodeKind::FunctionDeclaration, token),
22+
func_name(func_name), func_params(move(func_params)), func_body(func_body) {}
23+
24+
BlockStatement::BlockStatement(const Token *token,
25+
std::vector<StatementNode*> statements) noexcept :
26+
StatementNode(NodeKind::BlockStatement, token),
27+
statements(move(statements)){}

0 commit comments

Comments
 (0)