diff options
Diffstat (limited to 'grammer.h')
-rw-r--r-- | grammer.h | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -40,22 +40,35 @@ private: std::map<std::string, std::set<std::string>> ReverseBNF; // possible parent types of a given type -public: + // Tree specific void clear(); // Node specific std::string GetTypeOfNode(index_t node_id) const; - + bool IsRootNode(index_t node_id) const; + bool RootIsStartSymbol() const; + bool AllTokensUsed() const; + bool treeIsComplete() const; + std::vector<std::string>& getNodeExpectedChilds(node_id); + bool subTreeIsComplete(index_t node_id, index_t& to_fill); + size_t CommonPrefix(const std::vector<Token>& tokens, const std::vector<std::string>& types); + void AddFirstNode(); + bool AddRootNode(); + void RemoveLastNode(); + void ChangeNodeType(); index_t TrackBack(); - - void Validate(const std::string& Top, const BNF& bnf) const; - - void Dump(); + void Validate() const; + std::map<std::string, std::string> traverse(lower, upper); + std::vector<std::string> GetPath(std::string upper, std::string lower); + index_t AddNode(const std::string& name, const std::string& child_type, index_t parent_index); + void AddPath(const std::vector<std::string>& path, index_t current_index); + bool FillTree(); +public: Compiler(const BNF& bnf, const std::string& Top); - std::pair<index_t, std::vector<TreeNode>> compile(std::vector<Token> Tokens); + void DumpTree(); }; } // namespace Gram |