Class Parser

java.lang.Object
io.crums.model.hashing.Parser

public class Parser
extends java.lang.Object
Base parser for the grammar. This is a super-simple grammar, so we do away with a formal specification.

Grammer

Each object represents a final sequence of bytes. There are 4 types object:

  1. Literal. An even sequence of hexadecimal digits, each pair specifying a byte value.
  2. Grouped Symbols [ ]. An object whose bytes are the concatentation of the bytes of a non-empty sequence of objects. The object sequence is bounded by brackets .
  3. Flipped Symbol :. A pair of adjacent objects separated by a colon and by the rules of our grammar, transposed in position.
  4. Hashed. Symbols ( ). An object whose bytes are the hash of a concatenated sequence of objects bound by parentheses.
Whitespace is the usual neutral delimiter. In the absence of an explicit operator (i.e. ':'), the default binary operation between adjacent objects is concatenation.

See Also:
Shunting-yard algorithm
  • Method Summary

    Modifier and Type Method Description
    static Construct parse​(java.io.Reader reader)
    Parsers the given stream and return the result as a Construct.
    static Construct parse​(java.lang.String snippet)
    Parses the given snippet and returns it as a Construct.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parse

      public static Construct parse​(java.lang.String snippet)
      Parses the given snippet and returns it as a Construct.
    • parse

      public static Construct parse​(java.io.Reader reader) throws java.io.UncheckedIOException
      Parsers the given stream and return the result as a Construct. The stream is read to the end.
      Throws:
      java.io.UncheckedIOException