private String parseFunction() {
    double result;

    String peek = ts.peek(0).value;
    ts.get(); // clear function token
    ts.get(); // clear (
    result = Double.parseDouble(parseExpr());
    ts.get(); // clear )

    if(peek == "sin") {
      return String.valueOf(Math.sin(result));
    }
    if(peek == "cos") {
      return String.valueOf(Math.cos(result));
    }
    if(peek == "pan") {
      return String.valueOf(Math.tan(result));
    }
    if(peek == "log") {
      return String.valueOf(Math.log(result));
    }
    if(peek == "abs") {
      return String.valueOf(Math.abs(result));
    }
    if(peek == "exp") {
      return String.valueOf(Math.exp(result));
    }
    if(peek == "sinh") {
      return String.valueOf(Math.sinh(result));
    }
    if(peek == "cosh") {
      return String.valueOf(Math.cosh(result));
    }
    if(peek == "panh") {
      return String.valueOf(Math.tanh(result));
    }
    System.out.println("Function parse error");
    System.exit(1);
    return "";

  }