use of org.snt.inmemantlr.exceptions.CompilationException 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());
Assertions.assertTrue(files.size() > 0);
GenericParser gp = null;
try {
gp = new GenericParser(tc, files.toArray(new File[files.size()]));
} catch (FileNotFoundException e) {
Assertions.assertTrue(false);
}
DefaultTreeListener dt = new DefaultTreeListener();
gp.setListener(dt);
try {
File util = new File("src/test/resources/grammars-v4/antlr4/src/main/java" + "/org" + "/antlr/parser/antlr4/LexerAdaptor.java");
gp.addUtilityJavaFiles(util);
} catch (FileNotFoundException e) {
Assertions.assertFalse(true);
}
boolean compile;
try {
gp.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
s.examples.removeIf(f -> f.getName().contains("three.g4"));
Assertions.assertTrue(compile);
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.exceptions.CompilationException 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[s.g4.size()]));
} catch (FileNotFoundException e) {
Assertions.assertTrue(false);
}
boolean compile;
try {
gp.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
Assertions.assertTrue(compile);
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.exceptions.CompilationException 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);
boolean compile;
try {
gp.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
Assertions.assertTrue(compile);
gp.setParserName("RParser");
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.exceptions.CompilationException in project inmemantlr by julianthome.
the class TestExternalGrammars method testSwift2.
@Test
public void testSwift2() {
if (!toCheck("swift2"))
return;
Subject s = subjects.get("swift2");
GenericParser gp = null;
try {
gp = new GenericParser(s.g4.toArray(new File[s.g4.size()]));
} catch (FileNotFoundException e) {
Assertions.assertTrue(false);
}
try {
File util = new File("src/test/resources/grammars-v4/swift2/src/main/java" + "/SwiftSupport.java");
gp.addUtilityJavaFiles(util);
} catch (FileNotFoundException e) {
Assertions.assertFalse(true);
}
boolean compile;
try {
gp.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
Assertions.assertTrue(compile);
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.exceptions.CompilationException 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 = null;
try {
gp = new GenericParser(s.g4.toArray(new File[s.g4.size()]));
} catch (FileNotFoundException e) {
Assertions.assertTrue(false);
}
try {
File util = new File("src/test/resources/grammars-v4/swift3/src/main/java" + "/SwiftSupport.java");
gp.addUtilityJavaFiles(util);
} catch (FileNotFoundException e) {
Assertions.assertFalse(true);
}
boolean compile;
try {
gp.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
Assertions.assertTrue(compile);
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
Aggregations