Package com.igormaznitsa.jbbp.compiler
Class JBBPCompiler
java.lang.Object
com.igormaznitsa.jbbp.compiler.JBBPCompiler
The Class implements the compiler of a bin source script represented as a
text value into byte codes.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe Byte code of the 'ALIGN' command.static final intThe Byte code of the 'BIT' command.static final intThe Byte code of the 'BOOL' (boolean) command.static final intThe Byte code of the 'BYTE' command.static final intThe Byte code shows that field should be processed by custom field type processor.static final intThe Byte code of the 'INT' (integer) command.static final intThe Byte code of the 'LONG' command.static final intThe Byte code of the RESET COUNTER command.static final intThe Byte code of the 'SHORT' command.static final intThe Byte code of the SKIP command.static final intThe Byte code of the 'STRUCTURE_END' command.static final intThe Byte code of the 'STRUCTURE_START' command.static final intThe Byte code of the 'UBYTE' (unsigned byte) command.static final intp The Byte code of the 'USHORT' (unsigned short) command.static final intThe Byte code of the VAR command.static final intThe 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 intThe flag shows that the extra numeric value for field should be recognized not as number but as expression.static final intThe Flag shows that the type of data should be recognized differently.static final intThe Byte-Code Flag shows that the field is an array, but it must be omitted for unlimited field arrays.static final intThe Byte-Code Flag shows that a multibyte field must be decoded as Little-endian one.static final intThe Byte-Code Flag shows that the field is a named one.static final intThe Flag shows that the byte code is wide and contains extra byte in the next position of compiled block. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JBBPCompiledBlockstatic JBBPCompiledBlockcompile(String script, JBBPCustomFieldTypeProcessor customTypeFieldProcessor) Compile a text script into its byte code representation/
-
Field Details
-
CODE_ALIGN
public static final int CODE_ALIGNThe Byte code of the 'ALIGN' command.- See Also:
-
CODE_BIT
public static final int CODE_BITThe Byte code of the 'BIT' command.- See Also:
-
CODE_BOOL
public static final int CODE_BOOLThe Byte code of the 'BOOL' (boolean) command.- See Also:
-
CODE_UBYTE
public static final int CODE_UBYTEThe Byte code of the 'UBYTE' (unsigned byte) command.- See Also:
-
CODE_BYTE
public static final int CODE_BYTEThe Byte code of the 'BYTE' command.- See Also:
-
CODE_USHORT
public static final int CODE_USHORTp The Byte code of the 'USHORT' (unsigned short) command.- See Also:
-
CODE_SHORT
public static final int CODE_SHORTThe Byte code of the 'SHORT' command.- See Also:
-
CODE_INT
public static final int CODE_INTThe Byte code of the 'INT' (integer) command.- See Also:
-
CODE_LONG
public static final int CODE_LONGThe Byte code of the 'LONG' command.- See Also:
-
CODE_STRUCT_START
public static final int CODE_STRUCT_STARTThe Byte code of the 'STRUCTURE_START' command.- See Also:
-
CODE_STRUCT_END
public static final int CODE_STRUCT_ENDThe Byte code of the 'STRUCTURE_END' command.- See Also:
-
CODE_SKIP
public static final int CODE_SKIPThe Byte code of the SKIP command.- See Also:
-
CODE_VAR
public static final int CODE_VARThe 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_COUNTERThe 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_CUSTOMTYPEThe Byte code shows that field should be processed by custom field type processor.- See Also:
-
FLAG_NAMED
public static final int FLAG_NAMEDThe Byte-Code Flag shows that the field is a named one.- See Also:
-
FLAG_ARRAY
public static final int FLAG_ARRAYThe 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_ENDIANThe Byte-Code Flag shows that a multibyte field must be decoded as Little-endian one.- See Also:
-
FLAG_WIDE
public static final int FLAG_WIDEThe 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_WHOLESTREAMThe 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_EXPRESSIONThe 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_TYPEThe 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
- 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
-