use of org.snt.inmemantlr.GenericParser in project inmemantlr by julianthome.
the class TestExternalGrammars method testEcma.
@Test
public void testEcma() {
if (!toCheck("ecmascript"))
return;
Subject s = subjects.get("ecmascript");
GenericParser gp = null;
try {
gp = new GenericParser(s.g4.toArray(new File[0]));
} catch (FileNotFoundException e) {
fail();
}
assertDoesNotThrow(gp::compile);
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.GenericParser in project inmemantlr by julianthome.
the class TestExternalGrammars method testAntlr4.
@Test
public void testAntlr4() {
if (!toCheck("antlr4"))
return;
Subject s = subjects.get("antlr4");
// Exam
ToolCustomizer tc = t -> t.genPackage = "org.antlr.parser.antlr4";
Set<File> files = s.g4.stream().filter(v -> v.getName().matches("(ANTLRv4(Lexer|Parser)|LexBasic).g4")).collect(Collectors.toSet());
assertTrue(!files.isEmpty());
GenericParser gp = assertDoesNotThrow(() -> new GenericParser(tc, files.toArray(new File[0])));
DefaultTreeListener dt = new DefaultTreeListener();
gp.setListener(dt);
assertDoesNotThrow(() -> gp.addUtilityJavaFiles(new File("src/test/resources/grammars-v4/antlr4/src/main/java/org/antlr/parser/antlr4/LexerAdaptor.java")));
assertDoesNotThrow(gp::compile);
s.examples.removeIf(f -> f.getName().contains("three.g4"));
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.GenericParser in project inmemantlr by julianthome.
the class TestExternalGrammars method testR.
@Test
public void testR() {
if (!toCheck("r"))
return;
Subject s = subjects.get("r");
GenericParser gp = getParserForSubject(s, null);
assertDoesNotThrow(gp::compile);
gp.setParserName("RParser");
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.GenericParser in project inmemantlr by julianthome.
the class TestExternalGrammars method testSubject.
private void testSubject(Subject s, boolean skip) {
LOGGER.debug("test {}", s.name);
if (specialCases.contains(s.name) && skip) {
LOGGER.debug("skip {}", s.name);
return;
}
LOGGER.info("test {}", s.name);
GenericParser gp = getParserForSubject(s, null);
assertDoesNotThrow(gp::compile);
LOGGER.debug("successfully compiled grammar");
DefaultTreeListener dt = new DefaultTreeListener();
gp.setListener(dt);
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.GenericParser in project inmemantlr by julianthome.
the class TestExternalGrammars method testSwift3.
@Test
public void testSwift3() {
if (!toCheck("swift3"))
return;
Subject s = subjects.get("swift3");
GenericParser gp = assertDoesNotThrow(() -> new GenericParser(s.g4.toArray(new File[0])));
assertDoesNotThrow(() -> {
File util = new File("src/test/resources/grammars-v4/swift3/src/main/java" + "/SwiftSupport.java");
gp.addUtilityJavaFiles(util);
});
assertDoesNotThrow(gp::compile);
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
Aggregations