SF.net SVN: jython:[7263] trunk/sandbox/wierzbicki/antlr

[email protected] Thu, 24 Mar 2011 01:01:57 +0000
Newsgroups gmane.comp.lang.jython.cvs
Message-ID <[email protected]>
Revision: 7263
          http://jython.svn.sourceforge.net/jython/?rev=7263&view=rev
Author:   fwierzbicki
Date:     2011-03-24 01:01:57 +0000 (Thu, 24 Mar 2011)

Log Message:
-----------
Glob in Java to speed up grammar regression tests.

Modified Paths:
--------------
    trunk/sandbox/wierzbicki/antlr/run
    trunk/sandbox/wierzbicki/antlr/src/Main.java

Modified: trunk/sandbox/wierzbicki/antlr/run
===================================================================
--- trunk/sandbox/wierzbicki/antlr/run	2011-03-23 05:03:29 UTC (rev 7262)
+++ trunk/sandbox/wierzbicki/antlr/run	2011-03-24 01:01:57 UTC (rev 7263)
@@ -1 +1 @@
-java -classpath lib/antlr-3.1.jar:build Main $*
+java -classpath lib/antlr-3.1.jar:build Main /home/frank/svn/python/release26-maint

Modified: trunk/sandbox/wierzbicki/antlr/src/Main.java
===================================================================
--- trunk/sandbox/wierzbicki/antlr/src/Main.java	2011-03-23 05:03:29 UTC (rev 7262)
+++ trunk/sandbox/wierzbicki/antlr/src/Main.java	2011-03-24 01:01:57 UTC (rev 7263)
@@ -6,24 +6,46 @@
 public class Main {
     // override nextToken to set startPos (this seems too hard)
     public static class MyLexer extends PythonLexer {
-	public MyLexer(CharStream lexer) {
-	    super(lexer);
-	}
-	public Token nextToken() {
-	    startPos = getCharPositionInLine();
-	    return super.nextToken();
-	}
+        public MyLexer(CharStream lexer) {
+            super(lexer);
+        }
+        public Token nextToken() {
+            startPos = getCharPositionInLine();
+            return super.nextToken();
+        }
     }
 
     public static void main(String[] args) throws Exception {
-	CharStream input = new ANTLRFileStream(args[0]);
-	PythonLexer lexer = new MyLexer(input);
-	CommonTokenStream tokens = new CommonTokenStream(lexer);
-	tokens.discardOffChannelTokens(true);
-	PythonTokenSource indentedSource = new PythonTokenSource(tokens, "<test>");
-	tokens = new CommonTokenStream(indentedSource);
-	//System.out.println("tokens="+tokens.getTokens());
-	PythonParser parser = new PythonParser(tokens);
-	parser.file_input();
+        walk(new File(args[0]));
     }
+
+    public static void walk(File dir) throws Exception {
+        String pattern = ".py";
+ 
+        File pyfiles[] = dir.listFiles();
+        if(pyfiles != null) {
+            for(int i=0; i<pyfiles.length; i++) {
+                if(pyfiles[i].isDirectory()) {
+                    walk(pyfiles[i]);
+                } else {
+                    if(pyfiles[i].getName().endsWith(pattern)) {
+                        run(pyfiles[i].getPath());
+                    }
+                }
+            }
+        }
+    }
+
+
+    public static void run(String path) throws Exception {
+        System.out.println("parsing " + path);
+        CharStream input = new ANTLRFileStream(path);
+        PythonLexer lexer = new MyLexer(input);
+        CommonTokenStream tokens = new CommonTokenStream(lexer);
+        tokens.discardOffChannelTokens(true);
+        PythonTokenSource indentedSource = new PythonTokenSource(tokens, "<test>");
+        tokens = new CommonTokenStream(indentedSource);
+        PythonParser parser = new PythonParser(tokens);
+        parser.file_input();
+    }
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar