was playing with test java

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9561]
This commit is contained in:
parrt 2011-12-11 13:02:58 -08:00
parent 18ff004d83
commit b379a56c7f
2 changed files with 45 additions and 37 deletions

View File

@ -16,40 +16,47 @@ class TestJava {
public static JavaParser parser = null;
public static void main(String[] args) {
try {
long start = System.currentTimeMillis();
if (args.length > 0 ) {
// for each directory/file specified on the command line
for(int i=0; i< args.length;i++) {
doFile(new File(args[i])); // parse it
}
}
else {
System.err.println("Usage: java Main <directory or file name>");
}
long stop = System.currentTimeMillis();
System.out.println("Lexer total time " + lexerTime + "ms.");
System.out.println("Total time " + (stop - start) + "ms.");
doAll(args);
// doAll(args);
// doAll(args);
}
System.out.println("finished parsing OK");
System.out.println(LexerATNSimulator.ATN_failover+" lexer failovers");
System.out.println(LexerATNSimulator.match_calls+" lexer match calls");
System.out.println(ParserATNSimulator.ATN_failover+" parser failovers");
System.out.println(ParserATNSimulator.predict_calls +" parser predict calls");
System.out.println(ParserATNSimulator.retry_with_context +" retry_with_context after SLL conflict");
System.out.println(ParserATNSimulator.retry_with_context_indicates_no_conflict +" retry sees no conflict");
if ( profile ) {
System.out.println("num decisions "+profiler.numDecisions);
}
}
catch(Exception e) {
System.err.println("exception: "+e);
e.printStackTrace(System.err); // so we can get stack trace
}
}
static void doAll(String[] args) {
try {
lexerTime = 0;
long start = System.currentTimeMillis();
if (args.length > 0 ) {
// for each directory/file specified on the command line
for(int i=0; i< args.length;i++) {
doFile(new File(args[i])); // parse it
}
}
else {
System.err.println("Usage: java Main <directory or file name>");
}
long stop = System.currentTimeMillis();
System.out.println("Lexer total time " + lexerTime + "ms.");
System.out.println("Total time " + (stop - start) + "ms.");
System.out.println("finished parsing OK");
System.out.println(LexerATNSimulator.ATN_failover+" lexer failovers");
System.out.println(LexerATNSimulator.match_calls+" lexer match calls");
System.out.println(ParserATNSimulator.ATN_failover+" parser failovers");
System.out.println(ParserATNSimulator.predict_calls +" parser predict calls");
System.out.println(ParserATNSimulator.retry_with_context +" retry_with_context after SLL conflict");
System.out.println(ParserATNSimulator.retry_with_context_indicates_no_conflict +" retry sees no conflict");
if ( profile ) {
System.out.println("num decisions "+profiler.numDecisions);
}
}
catch(Exception e) {
System.err.println("exception: "+e);
e.printStackTrace(System.err); // so we can get stack trace
}
}
// This method decides what action to take based on the type of
// This method decides what action to take based on the type of
// file we are looking at
public static void doFile(File f)
throws Exception {
@ -102,6 +109,7 @@ class TestJava {
// Create a parser that reads from the scanner
if ( parser==null ) {
parser = new JavaParser(tokens);
// parser.getInterpreter().setContextSensitive(false);
// parser.setErrorHandler(new BailErrorStrategy<Token>());
// parser.getInterpreter().setContextSensitive(true);
}

View File

@ -45,12 +45,13 @@ class TestJavaLR {
public static boolean showTree = false;
public static void main(String[] args) {
doall(args);
// doall(args);
doAll(args);
// doAll(args);
}
public static void doall(String[] args) {
public static void doAll(String[] args) {
try {
lexerTime = 0;
long start = System.currentTimeMillis();
if (args.length > 0 ) {
// for each directory/file specified on the command line
@ -87,8 +88,7 @@ class TestJavaLR {
// This method decides what action to take based on the type of
// file we are looking at
public static void doFile(File f)
throws Exception {
public static void doFile(File f) throws Exception {
// If this is a directory, walk each file/dir in that directory
if (f.isDirectory()) {
String files[] = f.list();
@ -136,7 +136,7 @@ class TestJavaLR {
if ( parser==null ) {
parser = new JavaLRParser(null);
if ( showTree ) parser.setBuildParseTree(true);
parser.getInterpreter().setContextSensitive(true);
parser.getInterpreter().setContextSensitive(false);
// parser.setErrorHandler(new BailErrorStrategy<Token>());
// parser.getInterpreter().setContextSensitive(true);
}