add -gui option to view in gui window
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9747]
This commit is contained in:
parent
5c50e5f049
commit
db655f8f2c
|
@ -39,7 +39,7 @@ import java.lang.reflect.Method;
|
||||||
/** Run a lexer/parser combo, optionally printing tree string or generating
|
/** Run a lexer/parser combo, optionally printing tree string or generating
|
||||||
* postscript file. Optionally taking input file.
|
* postscript file. Optionally taking input file.
|
||||||
*
|
*
|
||||||
* $ java org.antlr.v4.runtime.misc.TestRig GrammarName startRuleName [-tree | -ps file.ps] [input-filename]
|
* $ java org.antlr.v4.runtime.misc.TestRig GrammarName startRuleName [-tree] [-gui] [-ps file.ps] [input-filename]
|
||||||
*/
|
*/
|
||||||
public class TestRig {
|
public class TestRig {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
@ -47,9 +47,10 @@ public class TestRig {
|
||||||
String startRuleName;
|
String startRuleName;
|
||||||
String inputFile = null;
|
String inputFile = null;
|
||||||
boolean printTree = false;
|
boolean printTree = false;
|
||||||
|
boolean gui = false;
|
||||||
String psFile = null;
|
String psFile = null;
|
||||||
if ( args.length < 2 ) {
|
if ( args.length < 2 ) {
|
||||||
System.err.println("java org.antlr.v4.runtime.misc.TestRig GrammarName startRuleName [-tree | -ps file.ps] [input-filename]");
|
System.err.println("java org.antlr.v4.runtime.misc.TestRig GrammarName startRuleName [-tree] [-gui] [-ps file.ps] [input-filename]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i=0;
|
int i=0;
|
||||||
|
@ -67,6 +68,9 @@ public class TestRig {
|
||||||
if ( arg.equals("-tree") ) {
|
if ( arg.equals("-tree") ) {
|
||||||
printTree = true;
|
printTree = true;
|
||||||
}
|
}
|
||||||
|
if ( arg.equals("-gui") ) {
|
||||||
|
gui = true;
|
||||||
|
}
|
||||||
else if ( arg.equals("-ps") ) {
|
else if ( arg.equals("-ps") ) {
|
||||||
if ( i>=args.length ) {
|
if ( i>=args.length ) {
|
||||||
System.err.println("missing filename on -ps");
|
System.err.println("missing filename on -ps");
|
||||||
|
@ -76,13 +80,14 @@ public class TestRig {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exec(grammarName, startRuleName, inputFile, printTree, psFile);
|
exec(grammarName, startRuleName, inputFile, printTree, gui, psFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void exec(String grammarName,
|
public static void exec(String grammarName,
|
||||||
String startRuleName,
|
String startRuleName,
|
||||||
String inputFile,
|
String inputFile,
|
||||||
boolean printTree,
|
boolean printTree,
|
||||||
|
boolean gui,
|
||||||
String psFile)
|
String psFile)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -121,6 +126,9 @@ public class TestRig {
|
||||||
if ( printTree ) {
|
if ( printTree ) {
|
||||||
System.out.println(tree.toStringTree(parser));
|
System.out.println(tree.toStringTree(parser));
|
||||||
}
|
}
|
||||||
|
if ( gui ) {
|
||||||
|
tree.inspect(parser);
|
||||||
|
}
|
||||||
if ( psFile!=null ) {
|
if ( psFile!=null ) {
|
||||||
tree.save(parser, psFile); // Generate postscript
|
tree.save(parser, psFile); // Generate postscript
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue