Esempio n. 1
0
 /**
  * Sets the input file and stub name strings.
  *
  * <p>This method needed to support packages that extend DAVE.
  *
  * @param fn the new file name
  */
 public void setInputFileName(String fn) {
   this.inputFileName = fn;
   this.stubName = DAVE.toStubName(fn);
 }
Esempio n. 2
0
  /** Parses any command-line options given. */
  private void parseOptions(String inArgs[]) {
    String exampleUse =
        "Usage: java DAVE [-v][-c][-d][-e][-h][-x][-i] [-o [Text_output_file]] DAVE-ML_document";
    int numArgs = inArgs.length;

    // Make sure we have at least the input file

    if (numArgs < 1) {
      System.out.println(exampleUse);
      System.out.println("Need at least one argument.");
      System.exit(0);
    }

    // Save arguments into field
    this.setArgs(inArgs);

    // Retrieve input file name
    this.inputFileName = this.args[numArgs - 1];

    // Don't deal with stub name if no filename provided
    if (this.inputFileName.startsWith("-")) {
      numArgs++; // adjust so we'll look at first argument
    } else {
      // Generate stub file name and list file name
      this.stubName = DAVE.toStubName(this.inputFileName);
      this.listFileName = this.stubName + ".txt";
    }

    // Parse remaining options
    if (numArgs > 1) {
      int parsedArgs = 0;
      if (matchOptionArgs("c", "count")) {
        this.genStatsFlag = true;
        parsedArgs++;
      }
      if (matchOptionArgs("d", "debug")) {
        this.verboseFlag = true;
        parsedArgs++;
      }
      if (matchOptionArgs("e", "eval")) {
        this.evaluate = true;
        parsedArgs++;
      }
      if (matchOptionArgs("i", "internal")) {
        this.createInternalValues = true;
        parsedArgs++;
      }
      if (matchOptionArgs("o", "list")) {
        this.makeListing = true;
        if (numArgs > (this.argNum + 2)) {
          if (!this.args[this.argNum + 1].startsWith("-")) {
            this.listFileName = this.args[this.argNum + 1];
          }
        }
        parsedArgs++;
      }
      if (matchOptionArgs("v", "version")) {
        this.noProcessingRequired = true;
        System.out.println("DAVE version " + getVersion());
        System.exit(0);
      }
      if (matchOptionArgs("x", "no-checkcase")) {
        this.ignoreCheckcases = true;
        parsedArgs++;
        System.out.println("Ignoring checkcases");
      }
      if (matchOptionArgs("h", "help")) {
        this.noProcessingRequired = true;
        this.helpRequested = true;
        parsedArgs++;
      }

      int numSwitches = this.numCmdLineSwitches();

      if (parsedArgs < numSwitches) {
        System.err.print("Unable to understand ");
        if (numSwitches == 1) {
          System.err.println("and parse option switch '" + this.args[this.argNum] + "'.");
        } else if (numSwitches == 2) {
          System.err.println("and parse both option switches.");
        } else {
          System.err.println("and parse all " + numSwitches + " option switches.");
        }
        System.err.println(exampleUse);
        System.exit(0);
      }
    }
  }