| 8879 | } |
| 8880 | |
| 8881 | token_type scan() |
| 8882 | { |
| 8883 | // initially, skip the BOM |
| 8884 | if (position.chars_read_total == 0 && !skip_bom()) |
| 8885 | { |
| 8886 | error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; |
| 8887 | return token_type::parse_error; |
| 8888 | } |
| 8889 | |
| 8890 | // read next character and ignore whitespace |
| 8891 | skip_whitespace(); |
| 8892 | |
| 8893 | // ignore comments |
| 8894 | while (ignore_comments && current == '/') |
| 8895 | { |
| 8896 | if (!scan_comment()) |
| 8897 | { |
| 8898 | return token_type::parse_error; |
| 8899 | } |
| 8900 | |
| 8901 | // skip following whitespace |
| 8902 | skip_whitespace(); |
| 8903 | } |
| 8904 | |
| 8905 | switch (current) |
| 8906 | { |
| 8907 | // structural characters |
| 8908 | case '[': |
| 8909 | return token_type::begin_array; |
| 8910 | case ']': |
| 8911 | return token_type::end_array; |
| 8912 | case '{': |
| 8913 | return token_type::begin_object; |
| 8914 | case '}': |
| 8915 | return token_type::end_object; |
| 8916 | case ':': |
| 8917 | return token_type::name_separator; |
| 8918 | case ',': |
| 8919 | return token_type::value_separator; |
| 8920 | |
| 8921 | // literals |
| 8922 | case 't': |
| 8923 | { |
| 8924 | 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')}}; |
| 8925 | return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); |
| 8926 | } |
| 8927 | case 'f': |
| 8928 | { |
| 8929 | 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')}}; |
| 8930 | return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); |
| 8931 | } |
| 8932 | case 'n': |
| 8933 | { |
| 8934 | 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')}}; |
| 8935 | return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); |
| 8936 | } |
| 8937 | |
| 8938 | // string |
nothing calls this directly
no test coverage detected