Examples of EACompileError


Examples of org.encog.ml.ea.exception.EACompileError

      final EncogProgram program, final ProgramNode[] args) {

    final String key = EncogOpcodeRegistry.createKey(name, args.length);

    if (!this.templateMap.containsKey(key)) {
      throw new EACompileError("Undefined function/operator: " + name
          + " with " + args.length + " args.");
    }

    final ProgramExtensionTemplate temp = this.templateMap.get(key);
    return new ProgramNode(program, temp, args);
View Full Code Here

Examples of org.encog.ml.ea.exception.EACompileError

    outputStack.push(leaf);
  }

  private void outputQueue(ProgramExtensionTemplate opp) {
    if (opp == this.LEFT_PAREN) {
      throw new EACompileError("Unmatched parentheses");
    }

    ProgramNode[] args = new ProgramNode[opp.getChildNodeCount()];

    for (int i = args.length - 1; i >= 0; i--) {
      if (this.outputStack.isEmpty()) {
        throw new EACompileError("Not enough arguments");
      }
      args[i] = this.outputStack.pop();
    }

    this.rootNode = this.holder.getFunctions().factorProgramNode(opp,
View Full Code Here

Examples of org.encog.ml.ea.exception.EACompileError

    this.parser.eatWhiteSpace();

    if (varName.toString().equals("true")) {
      if (neg) {
        throw new EACompileError("Invalid negative sign.");
      }
      ProgramNode v = this.holder.getFunctions().factorProgramNode("#const",
          holder, new ProgramNode[] {});
      v.getData()[0] = new ExpressionValue(true);
      outputQueue(v);
    } else if (varName.toString().equals("false")) {
      if (neg) {
        throw new EACompileError("Invalid negative sign.");
      }
      ProgramNode v = this.holder.getFunctions().factorProgramNode("#const",
          holder, new ProgramNode[] {});
      v.getData()[0] = new ExpressionValue(false);
      outputQueue(v);
    } else if (this.parser.peek() != '(') {
      ProgramNode v;
      // either a variable or a const, see which
      if (this.holder.getFunctions().isDefined(varName.toString(), 0)) {
        v = this.holder.getFunctions().factorProgramNode(
            varName.toString(), holder, new ProgramNode[] {});
      } else {
        this.holder.getVariables().setVariable(varName.toString(),
            new ExpressionValue(0));
        v = this.holder.getFunctions().factorProgramNode("#var", holder,
            new ProgramNode[] {});
        v.getData()[0] = new ExpressionValue((int) this.holder.getVariables()
            .getVariableIndex(varName.toString()));
      }

      if (neg) {
        v = this.holder.getFunctions().factorProgramNode("-", holder,
            new ProgramNode[] { v });
      }
      outputQueue(v);
    } else {
      ProgramExtensionTemplate temp = this.holder.getFunctions()
          .findFunction(varName.toString());
      if (temp == null) {
        throw new EACompileError("Undefined function: "
            + varName.toString());
      }
      functionQueue(temp);
    }
  }
View Full Code Here

Examples of org.encog.ml.ea.exception.EACompileError

      if (temp.getName().length() > 1) {
        this.parser.advance();
      }
      functionQueue(temp);
    } else {
      throw new EACompileError("Unknown symbol: " + ch1);
    }

  }
View Full Code Here

Examples of org.encog.ml.ea.exception.EACompileError

        str.append(ch);
      }
    } while ((ch != 34) && (ch > 0));

    if (ch != 34) {
      throw (new EACompileError("Unterminated string"));
    }

    ProgramNode v = this.holder.getFunctions().factorProgramNode("#const",
        holder, new ProgramNode[] {});
    v.getData()[0] = new ExpressionValue(str.toString());
View Full Code Here

Examples of org.encog.ml.ea.exception.EACompileError

        this.unary = false;
      } else if (ch == ',') {
        handleFunctionSeparator();
        this.unary = true;
      } else {
        throw new EACompileError("Unparsable character: " + ch);
      }
    }

    // pop off any functions still on the stack
    while (!this.functionStack.isEmpty()) {
View Full Code Here

Examples of org.encog.ml.ea.exception.EACompileError

    while(!this.parser.eol()) {
      this.parser.eatWhiteSpace();
     
      // read in the command
      if( this.parser.readChar()!='[' ) {
        throw new EACompileError("Expected [");
      }
      this.parser.eatWhiteSpace();
      StringBuilder cmd = new StringBuilder();
      while(this.parser.peek()!=']' && !this.parser.eol()) {
        cmd.append(this.parser.readChar());
      }
     
      if( this.parser.peek()!=']') {
        throw new EACompileError("Expected ]");
      }
      this.parser.advance();
     
     
      // parse out the command
      StringTokenizer tok = new StringTokenizer(cmd.toString(),":");
      String name = tok.nextToken();
      int childCount = Integer.parseInt(tok.nextToken());
      ProgramExtensionTemplate temp = EncogOpcodeRegistry.INSTANCE.findOpcode(name, childCount);
      if( temp==null ) {
        throw new EACompileError("Invalid instruction: " + name);
      }
     
      // build the arguments
      ProgramNode[] args = new ProgramNode[childCount];
      for(int i=args.length-1;i>=0;i--) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.