mstch/src/token.hpp

36 lines
928 B
C++
Raw Normal View History

2015-04-16 05:37:32 +08:00
#pragma once
2015-04-10 02:41:27 +08:00
#include <string>
namespace mstch {
2015-04-23 18:54:08 +08:00
class token {
public:
enum class type {
text, variable, section_open, section_close, inverted_section_open,
unescaped_variable, comment, partial, delimiter_change
2015-04-23 18:54:08 +08:00
};
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; };
2015-05-04 20:12:51 +08:00
const std::string& partial_prefix() const { return m_partial_prefix; };
void partial_prefix(const std::string& p_partial_prefix) {
m_partial_prefix = p_partial_prefix;
};
2015-04-23 18:54:08 +08:00
bool eol() const { return m_eol; }
2015-05-04 20:12:51 +08:00
void eol(bool eol) { m_eol = eol; }
2015-04-23 18:54:08 +08:00
bool ws_only() const { return m_ws_only; }
private:
type m_type;
std::string m_name;
std::string m_raw;
2015-05-04 20:12:51 +08:00
std::string m_partial_prefix;
2015-04-23 18:54:08 +08:00
bool m_eol;
bool m_ws_only;
type token_info(char c);
};
2015-04-10 02:41:27 +08:00
}