Class JBBPCompiler

java.lang.Object
com.igormaznitsa.jbbp.compiler.JBBPCompiler

public final class JBBPCompiler extends Object
The Class implements the compiler of a bin source script represented as a text value into byte codes.
Since:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The Byte code of the 'ALIGN' command.
    static final int
    The Byte code of the 'BIT' command.
    static final int
    The Byte code of the 'BOOL' (boolean) command.
    static final int
    The Byte code of the 'BYTE' command.
    static final int
    The Byte code shows that field should be processed by custom field type processor.
    static final int
    The Byte code of the 'INT' (integer) command.
    static final int
    The Byte code of the 'LONG' command.
    static final int
    The Byte code of the RESET COUNTER command.
    static final int
    The Byte code of the 'SHORT' command.
    static final int
    The Byte code of the SKIP command.
    static final int
    The Byte code of the 'STRUCTURE_END' command.
    static final int
    The Byte code of the 'STRUCTURE_START' command.
    static final int
    The Byte code of the 'UBYTE' (unsigned byte) command.
    static final int
    p The Byte code of the 'USHORT' (unsigned short) command.
    static final int
    The Byte code of the VAR command.
    static final int
    The flag (placed only in the second byte of wide codes) shows that the field is an array which calculated size or unlimited and must be read till the end of a stream.
    static final int
    The flag shows that the extra numeric value for field should be recognized not as number but as expression.
    static final int
    The Flag shows that the type of data should be recognized differently.
    static final int
    The Byte-Code Flag shows that the field is an array, but it must be omitted for unlimited field arrays.
    static final int
    The Byte-Code Flag shows that a multibyte field must be decoded as Little-endian one.
    static final int
    The Byte-Code Flag shows that the field is a named one.
    static final int
    The Flag shows that the byte code is wide and contains extra byte in the next position of compiled block.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    compile(String script)
     
    compile(String script, JBBPCustomFieldTypeProcessor customTypeFieldProcessor)
    Compile a text script into its byte code representation/

    Methods inherited from class java.lang.Object

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

    • CODE_ALIGN

      public static final int CODE_ALIGN
      The Byte code of the 'ALIGN' command.
      See Also:
    • CODE_BIT

      public static final int CODE_BIT
      The Byte code of the 'BIT' command.
      See Also:
    • CODE_BOOL

      public static final int CODE_BOOL
      The Byte code of the 'BOOL' (boolean) command.
      See Also:
    • CODE_UBYTE

      public static final int CODE_UBYTE
      The Byte code of the 'UBYTE' (unsigned byte) command.
      See Also:
    • CODE_BYTE

      public static final int CODE_BYTE
      The Byte code of the 'BYTE' command.
      See Also:
    • CODE_USHORT

      public static final int CODE_USHORT
      p The Byte code of the 'USHORT' (unsigned short) command.
      See Also:
    • CODE_SHORT

      public static final int CODE_SHORT
      The Byte code of the 'SHORT' command.
      See Also:
    • CODE_INT

      public static final int CODE_INT
      The Byte code of the 'INT' (integer) command.
      See Also:
    • CODE_LONG

      public static final int CODE_LONG
      The Byte code of the 'LONG' command.
      See Also:
    • CODE_STRUCT_START

      public static final int CODE_STRUCT_START
      The Byte code of the 'STRUCTURE_START' command.
      See Also:
    • CODE_STRUCT_END

      public static final int CODE_STRUCT_END
      The Byte code of the 'STRUCTURE_END' command.
      See Also:
    • CODE_SKIP

      public static final int CODE_SKIP
      The Byte code of the SKIP command.
      See Also:
    • CODE_VAR

      public static final int CODE_VAR
      The Byte code of the VAR command. It describes a request to an external processor to load values from a stream.
      See Also:
    • CODE_RESET_COUNTER

      public static final int CODE_RESET_COUNTER
      The Byte code of the RESET COUNTER command. It resets the inside counter of the input stream.
      See Also:
    • CODE_CUSTOMTYPE

      public static final int CODE_CUSTOMTYPE
      The Byte code shows that field should be processed by custom field type processor.
      See Also:
    • FLAG_NAMED

      public static final int FLAG_NAMED
      The Byte-Code Flag shows that the field is a named one.
      See Also:
    • FLAG_ARRAY

      public static final int FLAG_ARRAY
      The Byte-Code Flag shows that the field is an array, but it must be omitted for unlimited field arrays.
      See Also:
    • FLAG_LITTLE_ENDIAN

      public static final int FLAG_LITTLE_ENDIAN
      The Byte-Code Flag shows that a multibyte field must be decoded as Little-endian one.
      See Also:
    • FLAG_WIDE

      public static final int FLAG_WIDE
      The Flag shows that the byte code is wide and contains extra byte in the next position of compiled block.
      See Also:
    • EXT_FLAG_EXPRESSION_OR_WHOLESTREAM

      public static final int EXT_FLAG_EXPRESSION_OR_WHOLESTREAM
      The flag (placed only in the second byte of wide codes) shows that the field is an array which calculated size or unlimited and must be read till the end of a stream.
      See Also:
    • EXT_FLAG_EXTRA_AS_EXPRESSION

      public static final int EXT_FLAG_EXTRA_AS_EXPRESSION
      The flag shows that the extra numeric value for field should be recognized not as number but as expression.
      See Also:
    • EXT_FLAG_EXTRA_DIFF_TYPE

      public static final int EXT_FLAG_EXTRA_DIFF_TYPE
      The Flag shows that the type of data should be recognized differently. as float (if int), as double (if long), as virtual value (if skip).
      Since:
      1.4.0
      See Also:
  • Constructor Details

    • JBBPCompiler

      public JBBPCompiler()
  • Method Details

    • compile

      public static JBBPCompiledBlock compile(String script) throws IOException
      Throws:
      IOException
    • compile

      public static JBBPCompiledBlock compile(String script, JBBPCustomFieldTypeProcessor customTypeFieldProcessor) throws IOException
      Compile a text script into its byte code representation/
      Parameters:
      script - a text script to be compiled, must not be null.
      customTypeFieldProcessor - processor to process custom type fields, can be null
      Returns:
      a compiled block for the script.
      Throws:
      IOException - it will be thrown for an inside IO error.
      JBBPException - it will be thrown for any logical or work exception for the parser and compiler