diff options
Diffstat (limited to 'grammer.h')
-rw-r--r-- | grammer.h | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -30,12 +30,12 @@ private: std::vector<TreeNode> nodes; // Input - std::vector<std::string> tokens; + std::vector<Token> tokens; // Helper data index_t tokens_used{0}; // number of tokens used, this is also the next token index to use - const BNF &bnf; + BNF &bnf; // not const for access via operator[] const std::string& Top; std::map<std::string, std::set<std::string>> ReverseBNF; // possible parent types of a given type @@ -47,26 +47,26 @@ private: // Node specific std::string GetTypeOfNode(index_t node_id) const; bool IsRootNode(index_t node_id) const; - bool RootIsStartSymbol() const; + bool rootIsStartSymbol() const; bool AllTokensUsed() const; bool treeIsComplete() const; - std::vector<std::string>& getNodeExpectedChilds(node_id); + std::vector<std::string>& getNodeExpectedChilds(index_t 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 TrackBack(); void Validate() const; - std::map<std::string, std::string> traverse(lower, upper); + std::map<std::string, std::string> traverse(const std::string& lower, const std::string& 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); + index_t AddNode(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); + Compiler(BNF& bnf, const std::string& Top); std::pair<index_t, std::vector<TreeNode>> compile(std::vector<Token> Tokens); void DumpTree(); }; |