Parses a JSON5 value, writing JSON to the output.
| 39 | |
| 40 | // Parses a JSON5 value, writing JSON to the output. |
| 41 | void parseValue() { |
| 42 | switch(peekToken()) { |
| 43 | case 'n': |
| 44 | parseConstant("null"); |
| 45 | break; |
| 46 | case 't': |
| 47 | parseConstant("true"); |
| 48 | break; |
| 49 | case 'f': |
| 50 | parseConstant("false"); |
| 51 | break; |
| 52 | case '-': |
| 53 | case '+': |
| 54 | case '.': |
| 55 | case '0': case '1': case '2': case '3': case '4': |
| 56 | case '5': case '6': case '7': case '8': case '9': |
| 57 | parseNumber(); |
| 58 | break; |
| 59 | case '"': |
| 60 | case '\'': |
| 61 | parseString(); |
| 62 | break; |
| 63 | case '[': |
| 64 | parseSequence(false); |
| 65 | break; |
| 66 | case '{': |
| 67 | parseSequence(true); |
| 68 | break; |
| 69 | default: |
| 70 | fail("invalid start of JSON5 value"); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // Reads (and writes) a specific sequence of characters, failing if it doesn't match |
| 75 | // or if the next character is alphanumeric. |