/**
   * Return a set of the variables in the supplied expression. Note: Substitutions which are in the
   * constant table are not included.
   */
  public Set<String> getVariablesWithin(String exp) {
    Set<String> all = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    String add = null;

    if (separators == null) {
      StringBuilder sep = new StringBuilder(10);
      for (char chr = 0; chr < operators.length; chr++) {
        if (operators[chr] != null && !operators[chr].internal) {
          sep.append(chr);
        }
      }
      sep.append("()");
      separators = sep.toString();
    }

    for (StringTokenizer tkz = new StringTokenizer(exp, separators, true); tkz.hasMoreTokens(); ) {
      String tkn = tkz.nextToken().trim();

      if (tkn.length() != 0 && Character.isLetter(tkn.charAt(0))) {
        add = tkn;
      } else if (tkn.length() == 1 && tkn.charAt(0) == '(') {
        add = null;
      } else if (add != null && !constants.containsKey(add)) {
        all.add(add);
      }
    }
    if (add != null && !constants.containsKey(add)) {
      all.add(add);
    }
    return all;
  }
 public static String nextString() throws Exception {
   for (; st == null || !st.hasMoreTokens(); ) {
     String k1 = in.readLine();
     if (k1 == null) return null;
     st = new StringTokenizer(k1);
   }
   return st.nextToken();
 }
Example #3
0
 boolean hasNext() {
   while (tokenizer == null || !tokenizer.hasMoreTokens())
     try {
       tokenizer = new StringTokenizer(buff.readLine());
     } catch (Exception e) {
       return false;
     }
   return true;
 }
Example #4
0
 public String next() {
   while (tokenizer == null || !tokenizer.hasMoreTokens()) {
     try {
       tokenizer = new StringTokenizer(reader.readLine());
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
   }
   return tokenizer.nextToken();
 }
Example #5
0
 String nextToken() {
   while (st == null || !st.hasMoreTokens()) {
     try {
       st = new StringTokenizer(br.readLine());
     } catch (Exception e) {
       eof = true;
       return "0";
     }
   }
   return st.nextToken();
 }
Example #6
0
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            return st.nextToken();
        }
Example #7
0
 String nextToken() {
   while (st == null || !st.hasMoreTokens()) {
     try {
       st = new StringTokenizer(br.readLine());
     } catch (Exception e) {
       eof = true;
       break;
     }
   }
   String ret = buf;
   buf = eof ? "-1" : st.nextToken();
   return ret;
 }
Example #8
0
 String nextToken() {
   if (!createST) {
     try {
       curLine = readLine();
     } catch (Exception e) {
       eof = true;
     }
     return null;
   }
   while (st == null || !st.hasMoreTokens()) {
     try {
       curLine = readLine();
       st = new StringTokenizer(curLine);
     } catch (Exception e) {
       eof = true;
       break;
     }
   }
   String ret = buf;
   buf = eof ? "-1" : st.nextToken();
   return ret;
 }
Example #9
0
 String next() throws IOException {
   while (!tokenizer.hasMoreTokens()) {
     tokenizer = new StringTokenizer(reader.readLine());
   }
   return tokenizer.nextToken();
 }
Example #10
0
 String next() throws IOException {
   while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine().trim());
   return st.nextToken();
 }
 private static String nextToken() throws IOException {
   while (!tok.hasMoreTokens()) tok = new StringTokenizer(in.readLine());
   return tok.nextToken();
 }