deelang/src/syntax.cpp
2021-12-08 15:12:41 -06:00

50 lines
746 B
C++

#include <iostream>
#include <cstring>
#include <cstdlib>
#include "syntax.h"
using namespace std;
IdNode::IdNode(string *id) {
this->id = id;
}
void IdNode::display() {
cout << *id;
}
NumNode::NumNode(float num) {
this->num = num;
}
void NumNode::display() {
cout << num;
}
StringNode::StringNode(string* stringVal) {
this->stringVal = stringVal;
}
void StringNode::display() {
cout << *stringVal;
}
OpNode::OpNode(int op, Node *first, Node *second) {
this->op = op;
this->first = first;
this->second = second;
}
void OpNode::display() {
first->display();
cout << " " << (char)op << " ";
second->display();
}
void print_expression_list(NodeList *list) {
for (Node *expr : *list) {
expr->display();
}
}