public static void main()

in src/repl/PrologMain.java [26:95]


  public static void main(String argv[]) {
    try {
      System.err.println(HEADER);

      BlockingPrologControl p = new BlockingPrologControl();
      p.configureUserIO(System.in, System.out, System.err);
      p.setMaxDatabaseSize(256);

      List<File> toLoad = new ArrayList<>(4);
      long reductionLimit = Long.MAX_VALUE;
      Term goal = null;
      for (int i = 0; i < argv.length; i++) {
        String arg = argv[i];
        if (arg.equals("--enable-io")) {
          p.setEnabled(Prolog.Feature.IO, true);
        } else if (arg.equals("--enable-statistics")) {
          p.setEnabled(Prolog.Feature.STATISTICS, true);
        } else if (arg.startsWith("--max-database-size=")) {
          String v = arg.substring(arg.indexOf('=') + 1);
          p.setMaxDatabaseSize(Integer.parseInt(v, 10));
        } else if (arg.startsWith("--reduction-limit=")) {
          String v = arg.substring(arg.indexOf('=') + 1);
          reductionLimit = Long.parseLong(v, 10);
        } else if (arg.equals("-f") && i + 1 < argv.length) {
          toLoad.add(new File(argv[++i]));
        } else if (arg.startsWith("-")) {
          usage();
          System.exit(1);
        } else if (i == argv.length - 1) {
          goal = parseAtomicGoal(arg);
        } else {
          usage();
          System.exit(1);
        }
      }

      initializePackages(p, goal);
      for (File file : toLoad) {
        try (FileReader src = new FileReader(file);
            BufferedReader buf = new BufferedReader(src);
            PushbackReader in = new PushbackReader(buf, Prolog.PUSHBACK_SIZE)) {
          Term path = SymbolTerm.create(file.getPath());
          if (!p.execute(Prolog.BUILTIN, "consult_stream",
              path, new JavaObjectTerm(in))) {
            System.err.println();
            System.err.flush();
            System.exit(1);
          }
        }
        System.err.println();
        System.err.flush();
      }

      if (goal == null) {
        System.err.println();
        System.err.flush();
        goal = new StructureTerm(SymbolTerm.intern(":", 2), new Term[]{
          SymbolTerm.intern(Prolog.BUILTIN),
          SymbolTerm.create("cafeteria")});
      }

      p.setReductionLimit(reductionLimit);
      p.execute(Prolog.BUILTIN, "call", goal);
    } catch (HaltException e) {
      System.exit(e.getStatus());
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }