From 15a56fcb5f29b8507298144a835a819de652e788 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 14 Mar 2020 15:24:23 +0100 Subject: Prepare DFA --- lexer.h | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'lexer.h') diff --git a/lexer.h b/lexer.h index c6576d0..7f1be2d 100644 --- a/lexer.h +++ b/lexer.h @@ -5,50 +5,9 @@ namespace Lex { -struct TreeNode { - index_t parent{}; - std::vector childs; // fill char by char - std::vector child_names; // fill always - std::string name; -}; - -class Tree { -private: - std::map nodes; // index 0 = non existing; index starting at 1 - index_t node_num{}; - index_t root{}; - index_t last{}; - -public: - void clear(); - std::string GetType(); - bool Valid(const std::string& Top) const; - bool AddFirstNode(char c, const BNF& bnf, const std::map>& reverseBNF); - std::vector getParentTreeNode(const BNF& bnf, const std::map>& reverseBNF); - index_t GetLast(); - void AddRootNode(const TreeNode& newRootNode); - void RemoveRootNode(); - std::vector GetPath(std::string a, std::string b, const BNF& bnf, const std::map>& reverseBNF); - index_t AddNode(const std::string& name, const std::string& child_name, index_t parent_index, const BNF& bnf, const std::map>& reverseBNF); - void AddPath(const std::vector& path, index_t current_index, const BNF& bnf, const std::map>& reverseBNF); - bool Add(char c, const BNF& bnf, const std::map>& reverseBNF); - void Resolve(const BNF& bnf, const std::map>& reverseBNF); -}; - class Lexer { -private: - const BNF &bnf; - const std::string& Top; - - Location location{1, 0}; - - std::map> ReverseBNF; - - // to be called on token end - void FinalizeTree(Tree& tree, std::string& token, std::vector& result); - public: Lexer(const BNF& bnf, const std::string& Top); std::vector Lex(const std::string& s); -- cgit v1.2.3