use of org.snt.inmemantlr.memobjects.MemoryTuple in project inmemantlr by julianthome.
the class TestMemObjects method testAntlrObjectAccess.
@Test
public void testAntlrObjectAccess() {
GenericParser gp = null;
try {
gp = new GenericParser(grammar);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Assertions.assertNotNull(gp);
boolean compile;
try {
gp.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
Assertions.assertTrue(compile);
String s = FileUtils.loadFileContent(sfile.getAbsolutePath());
Assertions.assertTrue(s != null && !s.isEmpty());
MemoryTupleSet set = gp.getAllCompiledObjects();
Assertions.assertTrue(set != null && set.size() == 4);
for (MemoryTuple tup : set) {
LOGGER.debug("tuple name {}", tup.getClassName());
// for printing the source code
LOGGER.debug("source {}", tup.getSource().getClassName());
// for printing the byte code
for (MemoryByteCode mc : tup.getByteCodeObjects()) {
Objects.requireNonNull(mc, "MemoryByteCode must not be null");
LOGGER.debug("bc name: {}", mc.getClassName());
if (!mc.isInnerClass()) {
mc.getClassName().equals(tup.getSource().getClassName());
} else {
mc.getClassName().startsWith(tup.getSource().getClassName());
}
}
}
}
Aggregations