2015-04-10 02:41:27 +08:00
|
|
|
#ifndef _MSTCH_TOKEN_H_
|
|
|
|
#define _MSTCH_TOKEN_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace mstch {
|
|
|
|
class token {
|
2015-04-13 08:15:51 +08:00
|
|
|
public:
|
|
|
|
enum class type {
|
|
|
|
text, variable, section_open, section_close, inverted_section_open,
|
|
|
|
unescaped_variable, comment, partial
|
|
|
|
};
|
2015-04-15 07:42:51 +08:00
|
|
|
token(bool is_tag, bool eol, bool ws_only, const std::string& raw_val);
|
|
|
|
type token_type() const { return type_val; };
|
|
|
|
const std::string& content() const { return content_val; };
|
|
|
|
bool is_eol() const { return eol; }
|
|
|
|
bool is_ws_only() const { return ws_only; }
|
|
|
|
bool is_marked() const { return marked; }
|
|
|
|
void mark() { marked = true; };
|
2015-04-10 02:41:27 +08:00
|
|
|
private:
|
2015-04-15 22:13:23 +08:00
|
|
|
enum class parse_state { prews, postws, content };
|
2015-04-13 08:15:51 +08:00
|
|
|
type type_val;
|
2015-04-10 02:41:27 +08:00
|
|
|
std::string content_val;
|
2015-04-15 07:42:51 +08:00
|
|
|
bool eol;
|
|
|
|
bool ws_only;
|
|
|
|
bool marked;
|
2015-04-15 22:13:23 +08:00
|
|
|
type token_info(char c);
|
2015-04-10 02:41:27 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //_MSTCH_TOKEN_H_
|