Package scriptingLanguage

Examples of scriptingLanguage.Token


    return new JavaClass<T>(getName(), getSource(), getTokenType());
  }

  @Override
  public Token makePlaceholder() {
    return new Token(new JavaObject<T>(this, null), getTokenType());
  }
View Full Code Here


      }
      catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        throw new VariableNotFoundException(name + " is not defined in the current frame.");
      }
    if (data == null)
      return new Token();
    AbstractClass<?> output = determineType(data, frame);
    return new Token(output instanceof JavaClass ? new JavaObject<Object>((JavaClass<Object>) output, data) :
        ((PrimitiveClass<?>) output).makePrimitiveObject(data), (Type<Object>) output.getTokenType());
  }
View Full Code Here

  }
 
  @Override
  public Token eval(AbstractClass<?> caller, Token parameters, AbstractFrame frame) throws ArrayIndexOutOfBoundsException, IllegalArgumentException, InterpreterException {
    if (parameters.getCarType().equals(Interpreter.curlyBracesType)) { //This is a contents-initialized array
      Token value = (Token) parameters.getCar();
      ArrayList<Variable<?>> values = new ArrayList<>();
      do {
        Token val = new Token(), head = val;
        do {
          head = head.append(value.singular());
        } while (!(value = value.getNextToken()).isNull() && !value.getCarType().equals(Interpreter.separatorType));
        if ((Variable<?>) getSource() instanceof ArrayClass)
          values.add((Variable<?>) (val.getCarType().equals(Interpreter.curlyBracesType) ? getSource().eval(caller, val, frame).getCar() : Interpreter.evalInner(caller, val, frame).getCar()));
        else
          values.add((Variable<?>) frame.getInterpreter().eval(caller, val.getFirstToken(), frame).getCar());
      } while (!(value = value.getNextToken()).isNull());
      Object source = Array.newInstance(Variable.class, values.size());
      for (int i = 0; i < values.size(); i++)
        Array.set(source, i, values.get(i));
      return new Token(new ArrayObject((AbstractClass<Object>) getSource(), source), getTokenType());
    }
    int length = ((Variable<Integer>) parameters.getCar()).getSource();
    Object source = Array.newInstance(Variable.class, length);
    if ((parameters = parameters.getNextToken()).isNull())
      for (int i = 0; i < length; i++)
        Array.set(source, i, Interpreter.NULL);
    else
      for (int i = 0; i < length; i++)
        Array.set(source, i, getSource().eval(caller, parameters, frame).getCar());
    return new Token(new ArrayObject(this, source), getTokenType());
  }
View Full Code Here

    return new ArrayClass(getName(), getSource(), getTokenType());
  }

  @Override
  public Token makePlaceholder() {
    return new Token(new ArrayObject(getSource(), null), getTokenType());
  }
View Full Code Here

    return new JavaMethodClass(name, null, returnType, params, new Type<Object>(name));
  }
 
  @Override
  public Token makePlaceholder() {
    return new Token(new JavaMethod(this), getTokenType());
  }
View Full Code Here

    super((InterpreterMethodClass) base.getType(), base.getType(), method, base.getDeclared(), base.getParameters());
    this.superParams = superParams;
  }
 
  public static InterpreterConstructor init(InterpreterMethod base) {
    Token method = base.getSource(), superLine = new Token(), head = superLine;
    if (method.getCarType().equals(Interpreter.superType)) { //Then this is really easy because we already have the constructor
      method = method.getNextToken();
      Token params = (Token) method.getCar();
      if (!params.isNull())
        do {
          head = head.append(params.singular());
        } while (!(params = params.getNextToken()).getCarType().equals(Interpreter.endLineType) && !params.isNull());
      method = method.getNextToken();
    }
    else
      superLine = new Token();
    method.getLastToken().append(new Token("return", Interpreter.breakType, new Token("this", Interpreter.identifierType), Type.TOKEN));
    return new InterpreterConstructor(base, method, superLine);
   
  }
View Full Code Here

    return (PrimitiveObject<T>) eval(data).getCar();
  }
 
  @Override
  public Token eval(Object source) {
    return new Token(new PrimitiveObject<T>(this, (T) source), getTokenType());
  }
View Full Code Here

    return this;
  }
 
  @Override
  public Token makePlaceholder() {
    return new Token(new PrimitiveObject<T>(this, null), getTokenType());
  }
View Full Code Here

 
  public InterpreterRoot(Parser parser, Interpreter interpreter) {
    super(null, interpreter);
    variables = new LinkedHashMap<>();
    JavaClass<System> systemClass = new JavaClass<>("System", System.class);
    variables.put("System", new Pair<AbstractClass<?>, Token>(systemClass, new Token(systemClass, Interpreter.variableType)));
    JavaClass<Parser> parserClass = new JavaClass<>("Parser", Parser.class);
    variables.put("parser", new Pair<AbstractClass<?>, Token>(parserClass, new Token(new JavaObject<>(parserClass, parser), Interpreter.variableType)));
    try {
      JavaClass<Method> methodClass = new JavaClass<>("Method", Method.class);
      variables.put("print:{Object}", new Pair<AbstractClass<?>, Token>(methodClass,
          new Token(new JavaMethod(JavaMethodClass.make(Interpreter.voidClass, Interpreter.ObjectClass), System.out.getClass().getMethod("print", Object.class), System.out, this), methodClass.getTokenType())));
      variables.put("println:{Object}", new Pair<AbstractClass<?>, Token>(methodClass,
          new Token(new JavaMethod(JavaMethodClass.make(Interpreter.voidClass, Interpreter.ObjectClass), System.out.getClass().getMethod("println", Object.class), System.out, this), methodClass.getTokenType())));
    }
    catch (NoSuchMethodException | SecurityException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    super(name, source, returnType, parameters, tokenType);
  }
 
  @Override
  public Token makePlaceholder() {
    return new Token(new InterpreterMethod(this), getTokenType());
  }
View Full Code Here

TOP

Related Classes of scriptingLanguage.Token

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.