Package lipstone.joshua.parser.exceptions

Examples of lipstone.joshua.parser.exceptions.ParserException


    //In basic types:  answer = (b-a)/(2*N)*sigma
    answer = (max.subtract(min).divide(new BigDec(N).multiply(new BigDec(2)))).multiply(sigma);
    if (answer.subtract(last).abs().doubleValue() < accuracy)
      return answer;
    else if (N >= maxN)
      throw new ParserException("The integration system ran out of time", caller);
    else
      return trapezoidal(answer, N * 2);
  }
 
View Full Code Here


  public ConsCell runOperation(String operation, ConsCell input) throws ParserException {
    BigDec extra = null;
    if (operation.equals("zScore")) {
      ArrayList<ConsCell> parts = input.splitOnIdentifier(";");
      if (parts.size() != 2)
        throw new ParserException("The input for the zScore function did not include a valid comparator.", this);
      input = parts.get(0);
      extra = new BigDec(parser.run(parts.get(1)).toString());
    }
    ArrayList<ConsCell> list = input.splitOnSeparator();
    BigDec[] items = new BigDec[list.size()];
View Full Code Here

        ConsType.CONS_CELL, new ConsCell('/', ConsType.OPERATOR, new ConsCell(getSTDEV(1), ConsType.NUMBER), ConsType.CONS_CELL), ConsType.CONS_CELL));
    set.remove(item);
    if (result.length() == 1 && result.getCarType() == ConsType.NUMBER)
      return (BigDec) result.getCar();
    else
      throw new ParserException("Unable to find a numeric result to getzScore.", null);
  }
View Full Code Here

    if (parts.size() >= 2)
      numFactorial = round(parts.get(1));
    BigDec output = BigDec.ONE;
    ConsCell num = parser.run(parts.get(0));
    if (num.getCarType() != ConsType.NUMBER || !((BigDec) num.getCar()).isInt() || !((BigDec) num.getCar()).gteq(BigDec.ZERO))
      throw new ParserException("The factorial operation is only defined for arguments that evaluate to whole numbers", this);
    BigDec cap = (BigDec) num.getCar();
    if (cap.gteq(numFactorial))
      for (BigDec i = new BigDec(cap); i.gteq(BigDec.ONE); i = i.subtract(numFactorial))
        output = output.multiply(i);
    return output;
View Full Code Here

    if (!isValid(input)) {
      if (equation.equals("+"))
        return new ConsCell(BigDec.ONE, ConsType.NUMBER);
      if (equation.equals("-"))
        return new ConsCell(BigDec.MINUSONE, ConsType.NUMBER);
      throw new ParserException("Invalid Input", null);
    }
    // split based on '=' here
    ArrayList<String> initVars = new ArrayList<String>(vars);
    if (!equation.contains("="))
      input = getValue(input);
View Full Code Here

   *            the command to add to the queue
   * @throws ParserException
   */
  public void queueCommand(ConsCell command, ParserPlugin plugin) throws ParserException {
    if (commands.get(command.getCar()) == null)
      throw new ParserException("The plugin, " + plugin.getID() + ", attempted to queue a non-existent command", plugin);
    if (!commands.get(command.getCar()).getPlugin().getID().equals(plugin.getID()))
      throw new ParserException("The plugin, " + plugin.getID() + ", attempted to queue a command that is mapped to " + commands.get(command.getCar()).getPlugin().getID(), plugin);
    commandQueue.push(command);
  }
View Full Code Here

 
  private BigDec getY(ConsCell equation, BigDec x) throws ParserException {
    equation.replaceAll(new ConsCell(parser.getVars().get(0), ConsType.IDENTIFIER), new ConsCell(x, ConsType.NUMBER));
    ConsCell result = parser.run(equation);
    if (result.getCarType() != ConsType.NUMBER)
      throw new ParserException("Invalid equation", null);
    return (BigDec) result.getCar();
  }
View Full Code Here

        parser.setAngleType(parser.getAngleType(arg));
        saveData("angle", arguments.get(0));
        return new ConsCell("Set the angle type to " + arg, ConsType.IDENTIFIER);
      }
      else
        throw new ParserException(arguments.get(0) + " is not a valid angle type.  Valid angle types are: Degrees, Radians, Grads", this);
    }
    if (command.equals("showAngle") && arguments.size() == 0)
      return new ConsCell("The current angle type is " + parser.getAngleType() + ".", ConsType.IDENTIFIER);
    return null;
  }
View Full Code Here

TOP

Related Classes of lipstone.joshua.parser.exceptions.ParserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.