main.java

来自「Javacc 一个用来生成代码的脚本语言」· Java 代码 · 共 49 行

JAVA
49
字号
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));   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?