-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathast.cpp
More file actions
37 lines (30 loc) · 652 Bytes
/
Copy pathast.cpp
File metadata and controls
37 lines (30 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "ast.hpp"
#include <iostream>
void IdentifierNode::print() {
std::cout << id;
}
void NumberNode::print() {
std::cout << value;
}
void UnaryOpNode::print() {
std::cout << "(" << op;
operand->print();
std::cout << ")";
}
void BinaryOpNode::print() {
std::cout << "(";
left->print();
std::cout << " " << op << " ";
right->print();
std::cout << ")";
}
void FunctionNode::print() {
std::cout << "function " << id << "(" << param << ") { ";
body->print();
std::cout << " }";
}
void InlineFunctionNode::print() {
std::cout << name << "(";
arg->print();
std::cout << ")";
}