From 8828bd96989d839a1d34c5cfc625fefdfa80a136 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 6 Feb 2020 21:56:33 +0100 Subject: Fixed class --- grammer.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'grammer.h') diff --git a/grammer.h b/grammer.h index 996d023..0e9ed32 100644 --- a/grammer.h +++ b/grammer.h @@ -40,22 +40,35 @@ private: std::map> 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& getNodeExpectedChilds(node_id); + bool subTreeIsComplete(index_t node_id, index_t& to_fill); + size_t CommonPrefix(const std::vector& tokens, const std::vector& 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 traverse(lower, upper); + std::vector 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& path, index_t current_index); + bool FillTree(); +public: Compiler(const BNF& bnf, const std::string& Top); - std::pair> compile(std::vector Tokens); + void DumpTree(); }; } // namespace Gram -- cgit v1.2.3