Package scriptingLanguage.errors

Examples of scriptingLanguage.errors.InvalidAssignmentException


    int index = (int) ((Variable<Integer>) parameters.getCar()).getSource();
    if ((parameters = parameters.getNextToken()).isNull() || parameters.getCar().equals("get"))
      return new Token(Array.get(getSource(), index), ((Variable<?>) Array.get(getSource(), index)).getType().getTokenType());
    if (parameters.getCar().equals("set")) {
      if (((Variable<?>) (parameters = parameters.getNextToken()).getCar()).getType().extend((AbstractClass<?>) getType().getSource()) == -1)
        throw new InvalidAssignmentException("Cannot assign a value of the type, " + ((Variable<?>) parameters.getCar()).getType() + " to " + getType().getSource());
      Array.set(getSource(), index, parameters.getCar());
      return new Token(Interpreter.NULL, Interpreter.voidType);
    }
    return ((Variable<?>) Array.get(getSource(), index)).eval(caller, parameters, frame);
  }
View Full Code Here


    AbstractClass<?> clazz = depth == 0 ? frame.getType(type) : new ArrayClass(type, frame, new Type<Token>(type));
    if (depth != 0) {
      int len = indecies.length();
      if (len > 0) {
        if (len != depth)
          throw new InvalidAssignmentException("Either none of the dimensions specified for an array can have a size or all of them must have a size.");
        if (last.getCarType().equals(Interpreter.curlyBracesType))
          throw new UnexpectedTokenException("If the dimensions of an array have a specified length, then the contents of the array cannot be specified.");
        return clazz.eval(caller, indecies, frame);
      }
      if (len == 0 && !last.getCarType().equals(Interpreter.curlyBracesType))
View Full Code Here

 
  @Override
  public boolean writeVariable(String variable, Token value, boolean isNew) throws InterpreterException {
    if (isNew) {
      if (variables.containsKey(variable))
        throw new InvalidAssignmentException("The a variable called " + variable + " already exists in this frame.");
      variables.put(variable, new Pair<AbstractClass<?>, Token>(((Variable<?>) value.getCar()).getType(), value));
      return true;
    }
    try {
      return super.writeVariable(variable, value, false);
View Full Code Here

    this.variables = new LinkedHashMap<>();
  }
 
  public boolean writeVariable(String variable, AbstractClass<?> type) throws InvalidAssignmentException {
    if (variables.containsKey(variable))
      throw new InvalidAssignmentException("The a variable called " + variable + " already exists in this frame.");
    variables.put(variable, new Pair<AbstractClass<?>, Token>(type, null));
    return true;
  }
View Full Code Here

 
  @Override
  public boolean writeVariable(String variable, Token value, boolean isNew) throws InterpreterException {
    if (isNew) {
      if (variables.containsKey(variable))
        throw new InvalidAssignmentException("The a variable called " + variable + " already exists in this frame.");
      variables.put(variable, new Pair<AbstractClass<?>, Token>(((Variable<?>) value.getCar()).getType(), value));
      return true;
    }
    if (variables.containsKey(variable)) {
      Pair<AbstractClass<?>, Token> pair = variables.get(variable);
      if (((Variable<?>) value.getCar()).getType().extend(pair.getX()) != -1) {
        pair.setY(value);
        return true;
      }
      throw new InvalidAssignmentException("Cannot assign a value of the type, " + ((Variable<?>) value.getCar()).getType() + ", to the type " + pair.getX());
    }
    else if (previous != null && !(previous instanceof RootFrame))
      return previous.writeVariable(variable, value, false); //Cannot be a first assignment
    throw new VariableNotFoundException(variable + " has not been declared in this frame or scope.");
  }
View Full Code Here

TOP

Related Classes of scriptingLanguage.errors.InvalidAssignmentException

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.