Package

colossus

parsing

Permalink

package parsing

Visibility
  1. Public
  2. All

Type Members

  1. final case class DataSize(value: Long) extends AnyVal with Product with Serializable

    Permalink
  2. trait IntegerParser extends AnyRef

    Permalink
  3. class ParseException extends Exception

    Permalink
  4. sealed trait ParseStatus extends AnyRef

    Permalink
  5. class ParserSizeTracker extends AnyRef

    Permalink

    A ParserSizeTracker can wrap a stream parser to ensure that the object being parsed doesn't exceed a certain size.

    A ParserSizeTracker can wrap a stream parser to ensure that the object being parsed doesn't exceed a certain size.

    The size tracker is not exact. It simply looks at how many bytes are read off the DataBuffer each time the track method is called. Since in most cases databuffers are fairly small (128Kb right now for buffers coming out of the event loop), and since the primary purpose for this is to prevent OOM exceptions due to very large requests, the lack of precision isn't a huge issue.

  6. class SizedParseBuffer extends AnyRef

    Permalink
  7. class UnsizedParseBuffer extends AnyRef

    Permalink

Value Members

  1. object Combinators

    Permalink

    Streaming Parser Combinators

    Streaming Parser Combinators

    Overview

    A Parser[T] is an object that consumes a stream of bytes to produce a result of type T.

    A Combinator is a "higher-order" parser that takes one or more parsers to produce a new parser

    The Stream parsers are very fast and efficient, but because of this they need to make some tradeoffs. They are mutable, not thread safe, and in general are designed for network protocols, which tend to have very deterministic grammars.

    The Parser Rules:

    1. A parser must greedily consume the data stream until it produces a result 2. When a parser consumes the last byte necessary to produce a result, it must stop consuming the stream and return the new result while resetting its state

    Examples

    Use any parser by itself:

    val parser = bytes(4)
    val data = DataBuffer(ByteString("aaaabbbbccc")
    parser.parse(data) // Some(ByteString(97, 97, 97, 97))
    parser.parse(data) >> {bytes => bytes.utf8String} // Some("bbbb")
    parser.parse(data) // None

    Combine two parsers

    val parser = bytes(3) ~ bytes(2) >> {case a ~ b => a.ut8String + ":" + b.utf8String}
    parser.parse(DataBuffer(ByteString("abc"))) // None
    parser.parse(DataBuffer(ByteString("defgh"))) // Some("abc:de")
  2. object Complete extends ParseStatus with Product with Serializable

    Permalink
  3. object DataSize extends Serializable

    Permalink
  4. object Incomplete extends ParseStatus with Product with Serializable

    Permalink

Ungrouped