| 8808 | } |
| 8809 | |
| 8810 | token_type scan() |
| 8811 | { |
| 8812 | // initially, skip the BOM |
| 8813 | if (position.chars_read_total == 0 && !skip_bom()) |
| 8814 | { |
| 8815 | error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; |
| 8816 | return token_type::parse_error; |
| 8817 | } |
| 8818 | |
| 8819 | // read next character and ignore whitespace |
| 8820 | skip_whitespace(); |
| 8821 | |
| 8822 | // ignore comments |
| 8823 | while (ignore_comments && current == '/') |
| 8824 | { |
| 8825 | if (!scan_comment()) |
| 8826 | { |
| 8827 | return token_type::parse_error; |
| 8828 | } |
| 8829 | |
| 8830 | // skip following whitespace |
| 8831 | skip_whitespace(); |
| 8832 | } |
| 8833 | |
| 8834 | switch (current) |
| 8835 | { |
| 8836 | // structural characters |
| 8837 | case '[': |
| 8838 | return token_type::begin_array; |
| 8839 | case ']': |
| 8840 | return token_type::end_array; |
| 8841 | case '{': |
| 8842 | return token_type::begin_object; |
| 8843 | case '}': |
| 8844 | return token_type::end_object; |
| 8845 | case ':': |
| 8846 | return token_type::name_separator; |
| 8847 | case ',': |
| 8848 | return token_type::value_separator; |
| 8849 | |
| 8850 | // literals |
| 8851 | case 't': |
| 8852 | { |
| 8853 | std::array<char_type, 4> true_literal = {{static_cast<char_type>('t'), static_cast<char_type>('r'), static_cast<char_type>('u'), static_cast<char_type>('e')}}; |
| 8854 | return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); |
| 8855 | } |
| 8856 | case 'f': |
| 8857 | { |
| 8858 | std::array<char_type, 5> false_literal = {{static_cast<char_type>('f'), static_cast<char_type>('a'), static_cast<char_type>('l'), static_cast<char_type>('s'), static_cast<char_type>('e')}}; |
| 8859 | return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); |
| 8860 | } |
| 8861 | case 'n': |
| 8862 | { |
| 8863 | std::array<char_type, 4> null_literal = {{static_cast<char_type>('n'), static_cast<char_type>('u'), static_cast<char_type>('l'), static_cast<char_type>('l')}}; |
| 8864 | return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); |
| 8865 | } |
| 8866 | |
| 8867 | // string |
nothing calls this directly
no test coverage detected