2021-09-24 15:28:10 +00:00
|
|
|
#pragma once
|
|
|
|
#include <variant>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
namespace regular {
|
|
|
|
class RegularTree {
|
|
|
|
public:
|
|
|
|
class Node {
|
|
|
|
public:
|
2021-09-26 23:59:08 +00:00
|
|
|
enum class Type {
|
|
|
|
Addition, Concatenation, Word
|
|
|
|
};
|
|
|
|
enum class Modifier {
|
|
|
|
Plus, Star, None
|
|
|
|
};
|
|
|
|
|
2021-09-24 15:28:10 +00:00
|
|
|
Node();
|
2021-09-26 23:59:08 +00:00
|
|
|
Node(Type);
|
2021-09-24 15:28:10 +00:00
|
|
|
|
|
|
|
void Parse(const std::string&);
|
2021-09-26 23:59:08 +00:00
|
|
|
void Print() const;
|
|
|
|
std::vector<std::unique_ptr<Node>> children;
|
|
|
|
std::string word;
|
2021-09-24 15:28:10 +00:00
|
|
|
Type type;
|
2021-09-26 23:59:08 +00:00
|
|
|
Modifier modifier = Modifier::None;
|
2021-09-24 15:28:10 +00:00
|
|
|
private:
|
2021-09-26 23:59:08 +00:00
|
|
|
void ParseCurrentType(const std::string_view);
|
|
|
|
void Print(int nesting_level) const;
|
2021-09-24 15:28:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
RegularTree(const std::string&);
|
2021-09-26 23:59:08 +00:00
|
|
|
const Node& GetNode() const;
|
|
|
|
void Print() const;
|
2021-09-24 15:28:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Node node_;
|
|
|
|
};
|
|
|
|
}
|