Package AGEval

Examples of AGEval.InvalidGrammarException


      prop = rhsRaw;
    }
    try {
      return extendedGet(ast, node.equals("self") ? cls : lookupChildGeneral(cls, node), prop);
    } catch (InvalidGrammarException e) {
      throw new InvalidGrammarException("Bad lookupAttributeExtended: " + lhsRaw + " in class/interface " + cls.getName() + "\n" + e.getMessage());
    }
   
  }
View Full Code Here


    String res = backend.replaceTypeVals(openBody, sched._ast);
    for (Entry<String, String> e : indexedVariables.entrySet()) {
//      res = res.replaceAll(e.getValue() + " ", rhsToVal(e.getKey(), cls) + " ");
//      res = res.replaceAll(e.getValue() + "$", rhsToVal(e.getKey(), cls) + " ");
      if (!allowStep && (e.getKey().equals("$-") || e.getKey().contains("$i") || e.getKey().contains("$$"))) {
        throw new InvalidGrammarException("reduction variables ($ identifiers) must be in loop steps, error binding expression "
            + openBody + " with " + e.getKey() + " == " + e.getValue());
      }
      if (e.getKey().contains("$-")) {
        if (replaceStep) {
          //init
          throw new InvalidGrammarException("$acc must be in loop steps, error binding expression "
              + openBody + " with " + e.getKey() + " == " + e.getValue());
        } else {
          //step
          res = res.replaceAll(e.getValue() + " ", backend.rhsToVal(e.getKey(), cls, sched._ast) + " ");
          res = res.replaceAll(e.getValue() + ",", backend.rhsToVal(e.getKey(), cls, sched._ast) + ",");
View Full Code Here

            if (loop == null) {
              System.err.println("- loop cnd asgn, class " + cls.getName() + ": lhs " + lhs);
              for (String opt : sched._ast.extendedClasses.get(cls).idToLoop.keySet()) {
                System.err.println("  option: " + opt);
              }
              throw new InvalidGrammarException("could not find enclosing loop");
            }                 

            boolean inLoop = !"".equals(sched._ast.extendedClasses.get(cls).idToLoop.get(lhs));
            String fname = cls.getName().toLowerCase() + "_" + lhs.replace("@", "_");
            String assign = backend.lhsToAddress(lhsRaw, cls, sched._ast);
View Full Code Here

        for (LoopRecoverer.Block block : v.blocks) {
          switch (block.blockType) {
            case UNKNOWN:
              for (String a : block.assignments)
                System.err.println("  " + a);
              throw new InvalidGrammarException("Unknown block type");
            case LOOP:   
              openLoopClean(cls, block.maybeLoopVar, sched, block, exprToCall, exprPrinter, visit);             
              for (String lhs : block.assignments) {
                if (lhs.contains("_recur")) {                                   
                  String childName = lhs.split("_")[0].replace("unrolln", "");                 
                  //System.err.println("Recur child name: "+ childName);                 
                  if (childrenContains(sched._ast.extendedClasses.get(cls).multiChildren.keySet(), childName)) {
                    visit.put(cls, visit.get(cls) + backend.childrenRecur(cls, childName, visitNum, sched._ast));
                    visit.put(cls, visit.get(cls) + backend.logStmt(6, 2, "resume loop visit " + cls.getName(), "" + visitNum));
                  } else {
                    throw new InvalidGrammarException(cls.getName() + "::" + lhs + ": Cannot do a single child recursion (" + lhs + ") within a loop (" + block.maybeLoopVar + ")");                   
                  }
                } else {
                  if (lhs.contains("_step1") || lhs.contains("_step2")) continue;
                  visitStatement(cls, sched, visit, lhs, true, exprToCall, exprPrinter);
                }
              }
              closeLoopClean(cls, block.maybeLoopVar, sched, block, exprToCall, exprPrinter, visit);
              break;
            case STATEMENT:
              for (String lhs : block.assignments) {
                if (lhs.contains("_recur")) {
                  String childName = lhs.split("_")[0].replace("unrolln", "");
                  if (childrenContains(sched._ast.extendedClasses.get(cls).multiChildren.keySet(), childName)) {
                    throw new InvalidGrammarException(cls.getName() + "::" + lhs + ": Cannot do an array recursion (" + lhs + ") outside of a loop");
                  } else {
                    visit.put(cls, visit.get(cls) + "  " + backend.childRecur(cls, childName, visitNum));
                    visit.put(cls, visit.get(cls) + backend.logStmt(2, 2, "resume visit " + cls.getName(), "" + visitNum));
                  }
View Full Code Here

        String lhs = exprName.replace("_step", "");
        if (!sched.reductions.allClassWrites.get(cls).contains(lhs)) { //FIXME shouldn't be not !?
          //System.err.println("Check: " + lhs);
          for (String w : sched.reductions.allClassWrites.get(cls)) {
            String cmp = cls.getName().toLowerCase() + "_" + w.replace("@", "_");
            if (lhs.equals(cmp)) throw new InvalidGrammarException("Missing statement handler for write: " + cls.getName()+"::"+exprName);
          }
          return true;
       
      } else {
        if (AGEvaluatorSwipl.chainLoops) {         
          //might be a self loop
          /////// FIXME
          if (exprToCall.get(exprName+"_last") != null && exprPrinter.get(exprName+"_last") != null) return false;
          if (!sched.reductions.allClassWrites.get(cls).contains(exprName)) {
            //System.err.println("Check: " + lhs);
            for (String w : sched.reductions.allClassWrites.get(cls)) {  //FIXME shouldn't be not !?
              String cmp = cls.getName().toLowerCase() + "_" + w.replace("@", "_");
              if (exprName.equals(cmp)) throw new InvalidGrammarException("Missing statement handler for write: " + cls.getName()+"::"+exprName);
            }
            return true;
         
          ///////                 
         
          throw new InvalidGrammarException("Missing statement handler: " + cls.getName()+"::"+exprName);
        } else {
          System.err.println("Missing statement handler: " + cls.getName()+"::"+exprName);
        }
      } 
    }
View Full Code Here

    new_field = new Field(cls, property, ocl_type);
   
    // TODO: Add support for 'maybe' types
    if(new_field.isMaybeType()) {
      System.err.println(new_field.getClName() + " is a maybe type");
      throw new InvalidGrammarException("'maybe' types are not yet implemented in the OpenCL backend. Go yell at Matt.");
    }
   
    assignBuffer(new_field);
    fields.add(new_field);
   
View Full Code Here

    if(field.getClType().contains("VertexAndColor")) {
      return;
    }
   
    if(field.getClBufferName() != null) {
      throw new InvalidGrammarException("");
    }
   
    String buffer_name = field.getClType().toLowerCase().replaceAll("[- *]", "").replaceAll(":", "_") + "_buffer_1";

    CLBuffer buffer = null;
View Full Code Here

    if (lType.equals("int") || lType.equals("time") || lType.equals("color") || lType.equals("px")) {
      return "int";
    } else if (lType.equals("bool")) {
      // TODO: Implement C++ bool to OpenCL int casting routines for use in tree data transfers.
      // Until then, just throw an error if there's a bool.
      throw new InvalidGrammarException("Bool types not supported in OpenCL.");
    } else if(lType.equals("float")) {
      return "float";
    } else if(lType.equals("string") || lType.equals("std::string") || lType.equals("const char *")) {
      throw new InvalidGrammarException("String type not valid in OpenCL");
    } else if(lType.equals(enum_type_name.toLowerCase()) || lType.equals("displaytype") || lType.equals("refnametype")) {
      return enum_type_name;
    } else if (lType.equals("vbo")) {
      return "__global VertexAndColor*";
    } else {
      throw new InvalidGrammarException("Type " + type + " is not recognized by OpenCL generator. Can not translate to OpenCL type.");
    }
  }
View Full Code Here

                  if (loop == null) {
                    System.err.println("- loop cnd asgn, class " + cls.getName() + ": lhs " + lhs);
                    for (String opt : sched._ast.extendedClasses.get(cls).idToLoop.keySet()) {
                      System.err.println("  option: " + opt);
                    }
                    throw new InvalidGrammarException("could not find enclosing loop");
                  }                 
                 
                  boolean inLoop = !"".equals(sched._ast.extendedClasses.get(cls).idToLoop.get(lhs));
                  if (!inLoop) {                  
                    String fname = cls.getName().toLowerCase() + "_" + lhs;
View Full Code Here

 
  public String bindExpr(String openBody, HashMap<String,String> indexedVariables, AGEval.Class cls, boolean allowStep, boolean replaceStep, String acc, ALEParser ast) throws InvalidGrammarException {
    String res = openBody;
    for (Entry<String, String> e : indexedVariables.entrySet()) {
      if (!allowStep && (e.getKey().equals("$acc") || e.getKey().contains("$i"))) {
        throw new InvalidGrammarException("reduction variables ($ identifiers) must be in loop steps, error binding expression "
            + openBody + " with " + e.getKey() + " == " + e.getValue());
      }
      if ("$acc".equals(e.getKey())) {
        if (replaceStep) {
          //init
          throw new InvalidGrammarException("$acc must be in loop steps, error binding expression "
              + openBody + " with " + e.getKey() + " == " + e.getValue());
        } else {
          //step
          res = res.replaceAll(e.getValue() + " ",
              acc.replace("$", "\\$") + " ");
View Full Code Here

TOP

Related Classes of AGEval.InvalidGrammarException

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.