use of org.snt.inmemantlr.stream.CasedStreamProvider in project inmemantlr by julianthome.
the class TestExternalGrammars method testTSql.
@Test
public void testTSql() {
if (!toCheck("tsql"))
return;
Subject s = subjects.get("tsql");
Set<File> mfiles = s.g4.stream().filter(v -> v.getName().matches("TSql" + "(Lexer|Parser).g4")).collect(Collectors.toSet());
Assertions.assertTrue(mfiles.size() > 0);
GenericParser mparser = null;
try {
mparser = new GenericParser(mfiles.toArray(new File[mfiles.size()]));
} catch (FileNotFoundException e) {
Assertions.assertTrue(false);
}
Assertions.assertNotNull(mparser);
DefaultTreeListener mdt = new DefaultTreeListener();
boolean compile;
try {
mparser.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
mparser.setStreamProvider(new CasedStreamProvider(GenericParser.CaseSensitiveType.UPPER));
mparser.setListener(mdt);
Assertions.assertTrue(compile);
// seems to cause issues when running on windows
s.examples.removeIf(f -> f.getName().equals("full_width_chars.sql"));
verify(mparser, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.stream.CasedStreamProvider in project inmemantlr by julianthome.
the class TestExternalGrammars method testPHP.
@Test
public void testPHP() {
if (!toCheck("php"))
return;
Subject s = subjects.get("php");
s.g4.removeIf(f -> f.getName().equals("PHPLexer_CSharpSharwell.g4") || f.getName().equals("PHPLexer_Python.g4"));
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;
}
gp.setStreamProvider(new CasedStreamProvider(GenericParser.CaseSensitiveType.LOWER));
Assertions.assertTrue(compile);
s.examples = s.examples.stream().filter(f -> !f.getName().contains("alternativeSyntax.php")).collect(Collectors.toSet());
verify(gp, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.stream.CasedStreamProvider in project inmemantlr by julianthome.
the class TestExternalGrammars method testPlsql.
@Test
public void testPlsql() {
if (!toCheck("plsql"))
return;
Subject s = subjects.get("plsql");
Set<File> mfiles = s.g4.stream().filter(v -> v.getName().matches("PlSql" + "(Lexer|Parser).g4")).collect(Collectors.toSet());
Assertions.assertTrue(mfiles.size() > 0);
GenericParser mparser = null;
try {
mparser = new GenericParser(mfiles.toArray(new File[mfiles.size()]));
} catch (FileNotFoundException e) {
Assertions.assertTrue(false);
}
Assertions.assertNotNull(mparser);
DefaultTreeListener mdt = new DefaultTreeListener();
boolean compile;
try {
mparser.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
mparser.setStreamProvider(new CasedStreamProvider(GenericParser.CaseSensitiveType.UPPER));
mparser.setListener(mdt);
Assertions.assertTrue(compile);
verify(mparser, s.examples, s.nexamples, s.entrypoint);
}
use of org.snt.inmemantlr.stream.CasedStreamProvider in project inmemantlr by julianthome.
the class TestExternalGrammars method testMySQL.
@Test
public void testMySQL() {
if (!toCheck("mysql"))
return;
Subject s = subjects.get("mysql");
Set<File> mfiles = s.g4.stream().filter(v -> v.getName().matches("MySql" + "(Lexer|Parser).g4")).collect(Collectors.toSet());
Assertions.assertTrue(mfiles.size() > 0);
GenericParser mparser = null;
try {
mparser = new GenericParser(mfiles.toArray(new File[mfiles.size()]));
} catch (FileNotFoundException e) {
Assertions.assertTrue(false);
}
Assertions.assertNotNull(mparser);
DefaultTreeListener mdt = new DefaultTreeListener();
boolean compile;
try {
mparser.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}
mparser.setStreamProvider(new CasedStreamProvider(GenericParser.CaseSensitiveType.UPPER));
mparser.setListener(mdt);
Assertions.assertTrue(compile);
verify(mparser, s.examples, s.nexamples, s.entrypoint);
}
Aggregations