Read the bytes/chars from 'i' until 'j' as a String.
Read the bytes/chars from 'i' until 'j' as a String.
Read the byte/char at 'i' as a Char.
Read the byte/char at 'i' as a Char.
Note that this should not be used on potential multi-byte sequences.
Return true iff 'i' is at or beyond the end of the input (EOF).
Return true iff 'i' is at or beyond the end of the input (EOF).
The checkpoint() method is used to allow some parsers to store their progress.
The checkpoint() method is used to allow some parsers to store their progress.
Should be called when parsing is finished.
Should be called when parsing is finished.
The reset() method is used to signal that we're working from the given position, and any previous data can be released.
The reset() method is used to signal that we're working from the given position, and any previous data can be released. Some parsers (e.g. StringParser) will ignore release, while others (e.g. PathParser) will need to use this information to release and allocate different areas.
Valid parser states.
Valid parser states.
Generate a Char from the hex digits of "ሴ" (i.e.
Generate a Char from the hex digits of "ሴ" (i.e. "1234").
NOTE: This is only capable of generating characters from the basic plane. This is why it can only return Char instead of Int.
Used to generate error messages with character info and offsets.
Used to generate error messages with character info and offsets.
Used to generate messages for internal errors.
Used to generate messages for internal errors.
This should only be used in situations where a possible bug in the parser was detected. For errors in user-provided JSON, use die().
Parse and return the next JSON value and the position beyond it.
Parse and return the next JSON value and the position beyond it.
Parse the JSON constant "false".
Parse the JSON constant "false".
Note that this method assumes that the first character has already been checked.
Parse the JSON constant "null".
Parse the JSON constant "null".
Note that this method assumes that the first character has already been checked.
Parse the given number, and add it to the given context.
Parse the given number, and add it to the given context.
We don't actually instantiate a number here, but rather pass the string of for future use. Facades can choose to be lazy and just store the string. This ends up being way faster and has the nice side-effect that we know exactly how the user represented the number.
Parse the given number, and add it to the given context.
Parse the given number, and add it to the given context.
This method is a bit slower than parseNum() because it has to be sure it doesn't run off the end of the input.
Normally (when operating in rparse in the context of an outer array or object) we don't need to worry about this and can just grab characters, because if we run out of characters that would indicate bad input. This is for cases where the number could possibly be followed by a valid EOF.
This method has all the same caveats as the previous method.
Parse the string according to JSON rules, and add to the given context.
Parse the string according to JSON rules, and add to the given context.
This method expects the data to be in UTF-16, and access it as Char. It performs the correct checks to make sure that we don't interpret a multi-char code point incorrectly.
Parse a string that is known to have escape sequences.
Parse a string that is known to have escape sequences.
See if the string has any escape sequences.
See if the string has any escape sequences. If not, return the end of the string. If so, bail out and return -1.
This method expects the data to be in UTF-16 and accesses it as chars.
Parse the JSON constant "true".
Parse the JSON constant "true".
Note that this method assumes that the first character has already been checked.
Tail-recursive parsing method to do the bulk of JSON parsing.
Tail-recursive parsing method to do the bulk of JSON parsing.
This single method manages parser states, data, etc. Except for parsing non-recursive values (like strings, numbers, and constants) all important work happens in this loop (or in methods it calls, like reset()).
Currently the code is optimized to make use of switch statements. Future work should consider whether this is better or worse than manually constructed if/else statements or something else. Also, it may be possible to reorder some cases for speed improvements.
Trait used when the data to be parsed is in UTF-16.
This parser provides parseString(). Like ByteBasedParser it has fast/slow paths for string parsing depending on whether any escapes are present.
It is simpler than ByteBasedParser.