NodeTree now also has a link to the Symbol it represents.

This commit is contained in:
Nathan Braswell
2013-06-27 23:45:38 -04:00
parent 6a2977d12a
commit c2520ec2c4
6 changed files with 37 additions and 18 deletions

View File

@@ -6,15 +6,19 @@
#endif
#include <util.h>
#include <Symbol.h>
#include <vector>
#include <string>
#include <iostream>
//Circular references
class Symbol;
class NodeTree {
public:
NodeTree();
NodeTree(std::string name);
NodeTree(std::string name, Symbol* inSymbol);
~NodeTree();
void setParent(NodeTree* parent);
@@ -26,10 +30,13 @@ class NodeTree {
void removeChild(int index);
NodeTree* get(int index);
std::string getName();
std::string getName();
void setName(std::string);
Symbol* getSymbol();
void setSymbol(Symbol* symbol);
int size();
std::string DOTGraphString();
@@ -37,6 +44,7 @@ class NodeTree {
std::string DOTGraphStringHelper();
std::string getDOTName();
std::string name;
Symbol* symbol;
NodeTree* parent;
std::vector<NodeTree*> children;

View File

@@ -10,12 +10,16 @@
#include <vector>
#include <string>
//Circular references
class NodeTree;
class Symbol {
public:
Symbol(std::string name, bool isTerminal);
Symbol(std::string name, bool isTerminal, NodeTree* tree);
~Symbol();
bool const operator==(const Symbol &other);
std::string getName();
std::string toString();
Symbol* clone();
void setSubTree(NodeTree* tree);
@@ -23,6 +27,7 @@ class Symbol {
bool isTerminal();
private:
std::string name;
std::string value;
bool terminal;
NodeTree* subTree;