| 783 | } |
| 784 | |
| 785 | Json::Status |
| 786 | Json::parse(Json& json, const char*& p, const char* e, int context, int depth) |
| 787 | { |
| 788 | char w[4]; |
| 789 | long long x; |
| 790 | const char* a; |
| 791 | int A, B, C, D, c, d, i, u; |
| 792 | if (!depth) |
| 793 | return depth_exceeded; |
| 794 | for (a = p, d = +1; p < e;) { |
| 795 | switch ((c = *p++ & 255)) { |
| 796 | case ' ': // spaces |
| 797 | case '\n': |
| 798 | case '\r': |
| 799 | case '\t': |
| 800 | a = p; |
| 801 | break; |
| 802 | |
| 803 | case ',': // present in list and object |
| 804 | if (context & COMMA) { |
| 805 | context = 0; |
| 806 | a = p; |
| 807 | break; |
| 808 | } else { |
| 809 | return unexpected_comma; |
| 810 | } |
| 811 | |
| 812 | case ':': // present only in object after key |
| 813 | if (context & COLON) { |
| 814 | context = 0; |
| 815 | a = p; |
| 816 | break; |
| 817 | } else { |
| 818 | return unexpected_colon; |
| 819 | } |
| 820 | |
| 821 | case 'n': // null |
| 822 | if (context & (KEY | COLON | COMMA)) |
| 823 | goto OnColonCommaKey; |
| 824 | if (p + 3 <= e && READ32LE(p - 1) == READ32LE("null")) { |
| 825 | json.setNull(); |
| 826 | p += 3; |
| 827 | return success; |
| 828 | } else { |
| 829 | return illegal_character; |
| 830 | } |
| 831 | |
| 832 | case 'f': // false |
| 833 | if (context & (KEY | COLON | COMMA)) |
| 834 | goto OnColonCommaKey; |
| 835 | if (p + 4 <= e && READ32LE(p) == READ32LE("alse")) { |
| 836 | json.setBool(true); |
| 837 | p += 4; |
| 838 | return success; |
| 839 | } else { |
| 840 | return illegal_character; |
| 841 | } |
| 842 |
no test coverage detected