Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AST ast;
- ast.getRoot();
- #include "AST.h"
- Compiler::AST::AST() {
- }
- void Compiler::AST::addNode(Node node) {
- if(rootNull){
- setRoot(node);
- rootNull = false;
- }else{
- root.childNodes.push_back(node);
- }
- }
- Compiler::AST::Node Compiler::AST::getRoot() {
- return root;
- }
- void Compiler::AST::setRoot(Compiler::AST::Node node) {
- this->root = node;
- }
- #ifndef COMPILERS_ASSIGNMENT_AST_H
- #define COMPILERS_ASSIGNMENT_AST_H
- #include <string>
- #include <vector>
- #include <iostream>
- namespace Compiler {
- class AST {
- public:
- struct Node{
- std::string descriptor;
- std::vector <Node> childNodes;
- };
- typedef Node Node;
- AST();
- void addNode(Node);
- Node getRoot();
- private:
- Node root;
- bool rootNull = true;
- void setRoot(Node);
- };
- }
- #endif //COMPILERS_ASSIGNMENT_AST_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement