/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
return 0;
}
#ifndef NODE_H
#define NODE_H
#include <string>
#include <vector>
#include <memory>
class Node {
public:
virtual std::string toString(int level) const { return "some string";};//added return
std::string indent(int level);
};
#endif
#include "Node.hpp"
std::string Node::indent(int level) {
std::string indt;
for(int i = 0; i < level; i++) {
indt += "\t";
}
return indt;
}
#ifndef FUNCTION_NODE_H
#define FUNCTION_NODE_H
#include "TypeNode.hpp"
#include "ParamsNode.hpp"
#include "BlockNode.hpp"
#include "DeclarationNode.hpp"
class FunctionNode : public DeclarationNode {
std::shared_ptr<TypeNode> type;
std::string name;
std::shared_ptr<ParamsNode> paramList;
std::shared_ptr<BlockNode> block;
std::string FunctionNode::toString(int level) const override;
public:
FunctionNode(std::shared_ptr<TypeNode> type,
const std::string &name,
std::shared_ptr<ParamsNode> paramList,
std::shared_ptr<BlockNode> block)
: type(std::move(type)), name(name),
paramList(std::move(paramList)), block(std::move(block)) {}
};
#endif
#include "FunctionNode.hpp"
std::string FunctionNode::toString(int level) const {
std::string indt = indent(level);
std::string s = indt + "FunctionNode\n";
s += type->toString(level + 1);
s += indt + "\t" + name + "\n";
s += paramList->toString(level + 1);
s += block->toString(level + 1);
return s;
}