Yerbacon/src/headers/parsing/ParseComponents.hpp

28 lines
829 B
C++

#ifndef YERBACON_PARSECOMPONENTS_HPP
#define YERBACON_PARSECOMPONENTS_HPP
#include <iostream>
#include <vector>
using namespace std;
#include "../lex.hpp"
class ParseComponent {};
struct ParseTree: public ParseComponent {
private:
unsigned int compCount = 0;
protected:
vector<ParseComponent> subComponents;
public:
unsigned int& getCompCount() { return compCount; }
auto& getComponents() { return subComponents; }
void add(const ParseComponent& component) { subComponents.push_back(component); ++compCount; };
void addAll(const vector<ParseComponent>& components) { for (const auto& comp: components) add(comp); }
void operator<<(const ParseComponent& component) { this->add(component); }
ParseTree(): subComponents() {};
~ParseTree() = default;
};
#endif //YERBACON_PARSECOMPONENTS_HPP