use of org.snt.inmemantlr.memobjects.MemoryTupleSet 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();
}
assertNotNull(gp);
boolean compile;
try {
gp.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
assertTrue(compile);
String s = FileUtils.loadFileContent(sfile.getAbsolutePath());
assertTrue(s != null && !s.isEmpty());
MemoryTupleSet set = gp.getAllCompiledObjects();
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()) {
assertTrue(mc.getClassName().startsWith(tup.getSource().getClassName()));
} else {
assertEquals(tup.getSource().getClassName(), mc.getClassName());
}
}
}
}
Aggregations