Package lipstone.joshua.parser.util

Examples of lipstone.joshua.parser.util.ConsCell


    this.accuracy = accuracy;
    this.vars = new ArrayList<String>(vars);
    this.range = range;
    ArrayList<ConsCell> equationParts = equation.splitOnIdentifier("=");
    if (equationParts.size() == 1)
      equationParts.add(new ConsCell(BigDec.ZERO, ConsType.NUMBER));
    if (parser.containsVariables(equationParts.get(0), vars) && parser.containsVariables(equationParts.get(1), vars))
      equation = equationParts.get(0).append(parser.getCAS().invertSign(equation));
    else {
      if (parser.containsVariables(equationParts.get(0), vars)) {
        equation = equationParts.get(0);
        ConsCell temp = parser.run(parser.preProcess(equationParts.get(1)));
        if (temp.getCarType() != ConsType.NUMBER || temp.length() != 1)
          throw new UndefinedResultException("The NumericalSolver requires that the equation contain only one variable.", null);
        answer = (BigDec) temp.getCar();
      }
      if (parser.containsVariables(equationParts.get(1), vars)) {
        equation = equationParts.get(1);
        ConsCell temp = parser.run(parser.preProcess(equationParts.get(0)));
        if (temp.getCarType() != ConsType.NUMBER || temp.length() != 1)
          throw new UndefinedResultException("The NumericalSolver requires that the equation contain only one variable.", null);
        answer = (BigDec) temp.getCar();
      }
    }
    this.equation = parser.preProcess(equation).clone();
    variableCells = new ArrayList<ConsCell>();
    containsFactorial = this.equation.containsIdentifier("factorial");
View Full Code Here


public class AngleCommands extends ParserPlugin implements CommandPlugin, SettingsPlugin {
 
  @Override
  public void loadCommands() throws PluginConflictException {
    addCommand(new Command("setAngle", "set the angle to Degrees, Radians, or Grads", this));
    ConsCell temp = getData("angle");
    AngleType angle = (temp == null) ? parser.getAngleType() : parser.getAngleType(temp.toString());
    parser.setAngleType(angle);
    addCommand(new Command("showAngle", "shows the active angle measurment system", this));
  }
View Full Code Here

        arguments.set(0, Tokenizer.tokenizeString(arg));
      }
      if (parser.getAngleType(arg) != null) {
        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.util.ConsCell

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.