Пример #1
0
  private double doNamedVal(int beg, int end) {
    while (beg < end && Character.isWhitespace(expression.charAt(end))) {
      end--;
    } // since a letter triggers a named value, this can never reduce to beg==end

    String nam = expression.substring(beg, (end + 1));
    Double val;

    if ((val = constants.get(nam)) != null) {
      return val.doubleValue();
    } else if ((val = variables.get(nam)) != null) {
      isConstant = false;
      return val.doubleValue();
    } else if (relaxed) {
      isConstant = false;
      return 0.0;
    }

    throw exception(beg, "Unrecognized constant or variable \"" + nam + "\"");
  }
Пример #2
0
 private int skipWhitespace(String exp, int ofs, int end) {
   while (ofs <= end && Character.isWhitespace(exp.charAt(ofs))) {
     ofs++;
   }
   return ofs;
 }