aboutsummaryrefslogtreecommitdiff
path: root/lib/mstch/src/token.hpp
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-01-16 15:43:04 +0800
committerMistivia <i@mistivia.com>2025-01-16 15:53:58 +0800
commit8689a7c78c50676ea739f52fbcee9f091709f5c0 (patch)
treebbb72c68e5e1753f751133941a402caa43e29a16 /lib/mstch/src/token.hpp
parent00afb767ae37488d99f78363d031b898b1932354 (diff)
add mstch
Diffstat (limited to 'lib/mstch/src/token.hpp')
-rw-r--r--lib/mstch/src/token.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/mstch/src/token.hpp b/lib/mstch/src/token.hpp
new file mode 100644
index 0000000..fde8017
--- /dev/null
+++ b/lib/mstch/src/token.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <string>
+
+namespace mstch {
+
+using delim_type = std::pair<std::string, std::string>;
+
+class token {
+ public:
+ enum class type {
+ text, variable, section_open, section_close, inverted_section_open,
+ unescaped_variable, comment, partial, delimiter_change
+ };
+ token(const std::string& str, std::size_t left = 0, std::size_t right = 0);
+ type token_type() const { return m_type; };
+ const std::string& raw() const { return m_raw; };
+ const std::string& name() const { return m_name; };
+ const std::string& partial_prefix() const { return m_partial_prefix; };
+ const delim_type& delims() const { return m_delims; };
+ void partial_prefix(const std::string& p_partial_prefix) {
+ m_partial_prefix = p_partial_prefix;
+ };
+ bool eol() const { return m_eol; }
+ void eol(bool eol) { m_eol = eol; }
+ bool ws_only() const { return m_ws_only; }
+
+ private:
+ type m_type;
+ std::string m_name;
+ std::string m_raw;
+ std::string m_partial_prefix;
+ delim_type m_delims;
+ bool m_eol;
+ bool m_ws_only;
+ type token_info(char c);
+};
+
+}