summaryrefslogtreecommitdiffhomepage
path: root/grammer.h
diff options
context:
space:
mode:
Diffstat (limited to 'grammer.h')
-rw-r--r--grammer.h27
1 files changed, 20 insertions, 7 deletions
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<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