File: Main.java

package info (click to toggle)
javacc 5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 3,452 kB
  • ctags: 3,011
  • sloc: java: 21,299; xml: 2,024; sh: 120; makefile: 24
file content (48 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.*;

class Main
{
   private static int parseFilesFromFileList(String fileName)
   {
      LineNumberReader str = null;
      int cnt = 0;
      try
      {
         str = new LineNumberReader(new FileReader(new File(fileName))
);
         String s;

         while ((s = str.readLine()) != null)
         {
            try
            {
               cnt++;
               System.out.println("Parsing: " + s);
               new JavaParser(s).CompilationUnit();
            }
            catch(ParseException e) { e.printStackTrace(); }
            catch(TokenMgrError tme) { tme.printStackTrace(); }
         }
      }
      catch(Exception e) { e.printStackTrace(); }
      finally { if (str != null) try { str.close(); } catch(Exception e) {}  }

      return cnt;
   }

   public static void main(String[] args) throws Throwable
   {
      int cnt = 1;
      long l = System.currentTimeMillis();
      JavaParser parser;
      if (args[0].charAt(0) == '@')
      {
         cnt = parseFilesFromFileList(args[0].substring(1));
      }
      else
      {
         JavaParser.main(args);
      }
      System.out.println("Parsed " + cnt + " files in: " + (System.currentTimeMillis() - l));
   }
}