6 token::type token::token_info(char c) {
8 case '>': return type::partial;
9 case '^': return type::inverted_section_open;
10 case '/': return type::section_close;
11 case '&': return type::unescaped_variable;
12 case '#': return type::section_open;
13 case '!': return type::comment;
14 default: return type::variable;
18 token::token(const std::string& str, std::size_t left, std::size_t right):
19 m_raw(str), m_eol(false), m_ws_only(false)
21 if (left != 0 && right != 0) {
22 if (str[left] == '=' && str[str.size() - right - 1] == '=') {
23 m_type = type::delimiter_change;
24 } else if (str[left] == '{' && str[str.size() - right - 1] == '}') {
25 m_type = type::unescaped_variable;
26 m_name = {first_not_ws(str.begin() + left + 1, str.end() - right),
27 first_not_ws(str.rbegin() + 1 + right, str.rend() - left) + 1};
29 auto c = first_not_ws(str.begin() + left, str.end() - right);
30 m_type = token_info(*c);
31 if (m_type != type::variable)
32 c = first_not_ws(c + 1, str.end() - right);
33 m_name = {c, first_not_ws(str.rbegin() + right, str.rend() - left) + 1};
34 m_delims = {{str.begin(), str.begin() + left},
35 {str.end() - right, str.end()}};
39 m_eol = (str.size() > 0 && str[str.size() - 1] == '\n');
40 m_ws_only = (str.find_first_not_of(" \r\n\t") == std::string::npos);