add main to test gen.
This commit is contained in:
parent
e355fc44e2
commit
b15e66985e
|
@ -56,6 +56,38 @@ public class TestGenerator {
|
|||
|
||||
private final boolean visualize;
|
||||
|
||||
/**
|
||||
* $ java TestGenerator -o targetrootdir -templates target.test.stg -viz
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String outDir = ".";
|
||||
String targetSpecificTemplateFile = "";
|
||||
boolean viz = false;
|
||||
|
||||
int i = 0;
|
||||
while (args != null && i < args.length) {
|
||||
String arg = args[i];
|
||||
if (arg.startsWith("-o")) {
|
||||
i++;
|
||||
outDir = args[i];
|
||||
}
|
||||
else if (arg.startsWith("-templates")) {
|
||||
i++;
|
||||
targetSpecificTemplateFile = args[i];
|
||||
}
|
||||
else if (arg.startsWith("-viz")) {
|
||||
viz = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
TestGenerator gen = new TestGenerator("UTF-8",
|
||||
new File(targetSpecificTemplateFile),
|
||||
new File(outDir),
|
||||
viz);
|
||||
gen.execute();
|
||||
}
|
||||
|
||||
public TestGenerator(String encoding, File runtimeTemplates, File outputDirectory, boolean visualize) {
|
||||
this.encoding = encoding;
|
||||
this.runtimeTemplates = runtimeTemplates;
|
||||
|
|
|
@ -1,48 +1,44 @@
|
|||
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
TParser parser = new TParser(new CommonTokenStream(new TLexer(new ANTLRInputStream("b"))));
|
||||
parser.addParseListener(new MyTBaseListener());
|
||||
|
||||
parser.a();
|
||||
|
||||
System.out.println("######################");
|
||||
parser = new TParser(new CommonTokenStream(new TLexer(new ANTLRInputStream("x"))));
|
||||
parser.addParseListener(new MyTBaseListener());
|
||||
parser.b();
|
||||
}
|
||||
|
||||
private static class MyTBaseListener extends TBaseListener {
|
||||
@Override
|
||||
public void enterAlt1(TParser.Alt1Context ctx)
|
||||
{
|
||||
System.out.println("entering alt1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitAlt1(TParser.Alt1Context ctx)
|
||||
{
|
||||
System.out.println("exiting alt1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterB(TParser.BContext ctx) {
|
||||
System.out.println("enter b");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitB(TParser.BContext ctx) {
|
||||
System.out.println("exiting b");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterEveryRule(ParserRuleContext ctx) {
|
||||
System.out.println("enterEveryRule");
|
||||
}
|
||||
}
|
||||
// public static void main(String[] args)
|
||||
// {
|
||||
// TParser parser = new TParser(new CommonTokenStream(new TLexer(new ANTLRInputStream("b"))));
|
||||
// parser.addParseListener(new MyTBaseListener());
|
||||
//
|
||||
// parser.a();
|
||||
//
|
||||
// System.out.println("######################");
|
||||
// parser = new TParser(new CommonTokenStream(new TLexer(new ANTLRInputStream("x"))));
|
||||
// parser.addParseListener(new MyTBaseListener());
|
||||
// parser.b();
|
||||
// }
|
||||
//
|
||||
// private static class MyTBaseListener extends TBaseListener {
|
||||
// @Override
|
||||
// public void enterAlt1(TParser.Alt1Context ctx)
|
||||
// {
|
||||
// System.out.println("entering alt1");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void exitAlt1(TParser.Alt1Context ctx)
|
||||
// {
|
||||
// System.out.println("exiting alt1");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void enterB(TParser.BContext ctx) {
|
||||
// System.out.println("enter b");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void exitB(TParser.BContext ctx) {
|
||||
// System.out.println("exiting b");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void enterEveryRule(ParserRuleContext ctx) {
|
||||
// System.out.println("enterEveryRule");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.junit.Test;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/** Test parser execution.
|
||||
*
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/../gen3" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../antlr4-maven-plugin/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/playground" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../runtime-testsuite/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../.idea" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../antlr4-maven-plugin" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../build" />
|
||||
|
|
Loading…
Reference in New Issue