⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.java~7~

📁 《深入浅出设计模式》的完整源代码
💻 JAVA~7~
字号:
package littlecompiler;
/*让我们做一个小小的解释器程序,可以将自定义文法程序文件解释执行。解释器模式有点像演算法中的个别击破解释的方式,对每一个父节点
 我们剖析出其中的子节点的组合,然后再交由子节点剖析,直接剖析到终端节点为止。
 */
import java.util.*;
import java.io.*;

public class Client {
  public static void main (String[] args) {
    try {
      BufferedReader reader = new BufferedReader (new FileReader (args[ 0 ]));
      String text;
      while ( (text = reader.readLine ()) != null) {
        System.out.println ("text = \"" + text + "\"");
        Node node = new ProgramNode ();
        node.parse (new Context (text));
        System.out.println ("node = " + node);
        node.execute();
      }
    }
    catch (ArrayIndexOutOfBoundsException e) {
      System.err.println ("Usage: java Main yourprogram.txt");
    }
    catch (Exception e) {
      e.printStackTrace ();
    }
  }
}

⌨️ 快捷键说明

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