JBBPParser { public static JBBPParser prepare(final String script, final JBBPBitOrder bitOrder) { return new JBBPParser(script, bitOrder, null, 0); } private  JBBPParser(final String source, final JBBPBitOrder bitOrder, final JBBPCustomFieldTypeProcessor customFieldTypeProcessor, final int flags); static JBBPParser prepare(final String script, final JBBPBitOrder bitOrder); static JBBPParser prepare(final String script, final JBBPBitOrder bitOrder, final int flags); static JBBPParser prepare(final String script, final JBBPBitOrder bitOrder, final JBBPCustomFieldTypeProcessor customFieldTypeProcessor, final int flags); static JBBPParser prepare(final String script); static JBBPParser prepare(final String script, final JBBPCustomFieldTypeProcessor customFieldTypeProcessor); static JBBPParser prepare(final String script, final int flags); JBBPFieldStruct parse(final InputStream in); JBBPFieldStruct parse(final InputStream in, final JBBPVarFieldProcessor varFieldProcessor, final JBBPExternalValueProvider externalValueProvider); int getFlags(); JBBPFieldStruct parse(final byte[] array); JBBPFieldStruct parse(final byte[] array, final JBBPVarFieldProcessor varFieldProcessor, final JBBPExternalValueProvider externalValueProvider); long getFinalStreamByteCounter(); JBBPCompiledBlock getCompiledBlock(); List<ResultSrcItem> convertToSrc(final TargetSources target, final String name); static final int FLAG_SKIP_REMAINING_FIELDS_IF_EOF; static final int FLAG_NEGATIVE_EXPRESSION_RESULT_AS_ZERO; }
@Test public void testFieldNameCaseInsensetive_ExceptionForDuplicationOfFieldNames() throws Exception { assertThrows(JBBPCompilationException.class, () -> JBBPParser.prepare("bool Field1; byte field1;")); }
@Test public void testCompile_Value() { JBBPParser.prepare("val:34 value;"); JBBPParser.prepare("val:(1+$$) value;"); JBBPParser.prepare("val:(1<<4) value;"); }
@Test public void testCompile_Value_CompilationErrors() { assertThrows(JBBPCompilationException.class, () -> JBBPParser.prepare("val;")); assertThrows(JBBPCompilationException.class, () -> JBBPParser.prepare("val:1;")); assertThrows(JBBPCompilationException.class, () -> JBBPParser.prepare("val:(3+5);")); assertThrows(JBBPCompilationException.class, () -> JBBPParser.prepare("val a;")); assertThrows(JBBPCompilationException.class, () -> JBBPParser.prepare("val:3 [_];")); assertThrows(JBBPCompilationException.class, () -> JBBPParser.prepare("val:3 [_] field;")); }
@Test public void testParse_StringFieldInExpression_NoErrorDuringCompilation() throws Exception { JBBPParser.prepare("byte a; stringj b; byte[a+b];"); JBBPParser.prepare("stringj b; byte[b];"); }