final class Parser[F[_], A] extends BaseParser[F, A]
Parser is able to parse chunks of data (encoded as Option[ByteBuffer] instances) and parse asynchronously. You can use the factory methods in the companion object to instantiate an async parser.
The async parser's fields are described below:
The (state, curr, stack) triple is used to save and restore parser state between async calls. State also helps encode extra information when streaming or unwrapping an array.
The (data, len, allocated) triple is used to manage the underlying data the parser is keeping track of. As new data comes in, data may be expanded if not enough space is available.
The offset parameter is used to drive the outer async parsing. It stores similar information to curr but is kept separate to avoid "corrupting" our snapshot.
The done parameter is used internally to help figure out when the atEof() parser method should return true. This will be set when apply(None) is called.
The streamMode parameter controls how the asynchronous parser will be handling multiple values. There are three states:
1: An array is being unwrapped. Normal JSON array rules apply (Note that if the outer value observed is not an array, this mode will toggle to the -1 mode).
0: A stream of individual JSON elements separated by whitespace are being parsed. We can return each complete element as we parse it.
-1: No streaming is occuring. Only a single JSON value is allowed.
- Annotations
- @SuppressWarnings()
- Alphabetic
- By Inheritance
- Parser
- BaseParser
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
absorb(s: String)(implicit F: Sync[F]): F[Either[ParseException, A]]
- Definition Classes
- BaseParser
- Annotations
- @SuppressWarnings()
-
final
def
absorb(bytes: Array[Byte])(implicit F: Sync[F]): F[Either[ParseException, A]]
- Definition Classes
- BaseParser
- Annotations
- @SuppressWarnings()
-
final
def
absorb(buf: ByteBuffer)(implicit F: Sync[F]): F[Either[ParseException, A]]
- Definition Classes
- BaseParser
- Annotations
- @SuppressWarnings()
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
final
def
at(i: Int, k: Int): CharSequence
Access a byte range as a string.
Access a byte range as a string.
Since the underlying data are UTF-8 encoded, i and k must occur on unicode boundaries. Also, the resulting String is not guaranteed to have length (k - i).
- Attributes
- protected[this]
- Definition Classes
- BaseParser
- Annotations
- @SuppressWarnings()
-
final
def
at(i: Int): Char
- Attributes
- protected[this]
- Definition Classes
- BaseParser
- Annotations
- @SuppressWarnings()
-
final
def
atEof(i: Int): Boolean
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
final
def
byte(i: Int): Byte
This is a specialized accessor for the case where our underlying data are bytes not chars.
This is a specialized accessor for the case where our underlying data are bytes not chars.
- Attributes
- protected[this]
- Definition Classes
- BaseParser
- Annotations
- @SuppressWarnings()
-
def
checkpoint(state: Int, i: Int, ring: Long, offset: Int, fallback: BList): Unit
We use this to keep track of the last recoverable place we've seen.
We use this to keep track of the last recoverable place we've seen. If we hit an AsyncException, we can later resume from this point.
This method is called during every loop of rparse, and the arguments are the exact arguments we can pass to rparse to continue where we left off.
- Attributes
- protected[this]
-
def
churn(): Either[ParseException, A]
More data has been received, consume as much as possible.
More data has been received, consume as much as possible.
- Attributes
- protected[this]
- Definition Classes
- Parser → BaseParser
- Annotations
- @SuppressWarnings()
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
column(i: Int): Int
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
final
var
curr: Int
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
def
descape(s: CharSequence): Char
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.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
final
def
die(i: Int, msg: String): Nothing
Used to generate error messages with character info and offsets.
Used to generate error messages with character info and offsets.
- Attributes
- protected[this]
- Definition Classes
- BaseParser
- Annotations
- @SuppressWarnings()
-
final
var
done: Boolean
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
error(msg: String): Nothing
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().
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
finish(implicit F: Sync[F]): F[Either[ParseException, A]]
- Definition Classes
- BaseParser
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
newline(i: Int): Unit
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
var
offset: Int
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
def
parse(i: Int): Int
Parse and return the next JSON value and the position beyond it.
Parse and return the next JSON value and the position beyond it.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
def
parseFalse(i: Int): Unit
Parse the JSON constant "false".
Parse the JSON constant "false".
Note that this method assumes that the first character has already been checked.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
def
parseNull(i: Int): Unit
Parse the JSON constant "null".
Parse the JSON constant "null".
Note that this method assumes that the first character has already been checked.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
def
parseNum(i: Int): Int
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.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
def
parseNumSlow(i: Int): Int
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.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
def
parseString(i: Int, key: Boolean): Int
Parse the JSON string starting at 'i' and save it into the plate.
Parse the JSON string starting at 'i' and save it into the plate. If key is true, save the string with 'nestMap', otherwise use 'str'.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
def
parseStringSimple(i: Int): Int
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-8 and accesses it as bytes. Thus we can just ignore any bytes with the highest bit set.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
def
parseTrue(i: Int): Unit
Parse the JSON constant "true".
Parse the JSON constant "true".
Note that this method assumes that the first character has already been checked.
- Attributes
- protected[this]
- Annotations
- @SuppressWarnings()
-
final
def
reset(i: Int): Int
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
def
rparse(state: Int, j: Int, ring: Long, offset: Int, fallback: BList): Int
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.
- Attributes
- protected[this]
- Annotations
- @tailrec() @SuppressWarnings()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
unsafeData(): Array[Byte]
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
final
def
unsafeLen(): Int
- Attributes
- protected[this]
- Definition Classes
- BaseParser
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )