8117 {
8118
8120 {
8121 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8122 return token_type::parse_error;
8123 }
8124
8125
8126 skip_whitespace();
8127
8128
8130 {
8132 {
8133 return token_type::parse_error;
8134 }
8135
8136
8137 skip_whitespace();
8138 }
8139
8141 {
8142
8143 case '[':
8144 return token_type::begin_array;
8145
8146 case ']':
8147 return token_type::end_array;
8148
8149 case '{':
8150 return token_type::begin_object;
8151
8152 case '}':
8153 return token_type::end_object;
8154
8155 case ':':
8156 return token_type::name_separator;
8157
8158 case ',':
8159 return token_type::value_separator;
8160
8161
8162 case 't':
8163 {
8164 std::array<char_type, 4> true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}};
8165 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8166 }
8167
8168 case 'f':
8169 {
8170 std::array<char_type, 5> false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}};
8171 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8172 }
8173
8174 case 'n':
8175 {
8176 std::array<char_type, 4> null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}};
8177 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8178 }
8179
8180
8181 case '\"':
8183
8184
8185 case '-':
8186 case '0':
8187 case '1':
8188 case '2':
8189 case '3':
8190 case '4':
8191 case '5':
8192 case '6':
8193 case '7':
8194 case '8':
8195 case '9':
8197
8198
8199
8200 case '\0':
8201 case std::char_traits<char_type>::eof():
8202 return token_type::end_of_input;
8203
8204
8205 default:
8207 return token_type::parse_error;
8208 }
8209 }
const bool ignore_comments
whether comments should be ignored (true) or signaled as errors (false)
char_int_type current
the current character
bool skip_bom()
skip the UTF-8 byte order mark
const char * error_message
a description of occurred lexer errors
position_t position
the start position of the current token
token_type scan_number()
scan a number literal
token_type scan_string()
scan a string literal
token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
bool scan_comment()
scan a comment
std::size_t chars_read_total
the total number of characters read