Package AGEval

Examples of AGEval.InvalidGrammarException


    for (Entry<String, ALEParser.ExtendedVertex> e : ec.extendedVertices.entrySet())
      if (e.getKey().toLowerCase().equals(uProp)) return e.getValue();   
   
    AGEval.IFace cls = getIFaceByEc(ast, ec);
    if (cls instanceof AGEval.Class) return extendedGet(ast, cls.getInterface(), uProp); //retry on interface
    throw new InvalidGrammarException("Extended get on class fail: " + clsRaw.getName() + " (ec: " + cls.getName() + ") for " + prop);
    /*
    AGEval.IFace iface = cls.getInterface();
    if (iface == cls || iface == null) throw new InvalidGrammarException("Extended get on interface fail: " + cls.getName() + " for " + prop);   
    else
      for (Entry<String, ALEParser.ExtendedVertex> e : ast.extendedClasses.get(iface).extendedVertices.entrySet())
View Full Code Here


    if (res != null) return res;
    else {
      for (Entry<String, AGEval.IFace> e: cls.getChildMappings().entrySet()) {
        if (e.getKey().toLowerCase().equals(child)) {
          if (e.getValue() != null) return e.getValue();
          else throw new InvalidGrammarException("Looked up null child: " + cls.getName() + "'s " + child);         
        }
      }
    }
    throw new InvalidGrammarException("Cannot find child " + child + " of " + cls.getName());
   
  }
View Full Code Here

    }
    try {
      return extendedGet(ast, node.equals("self") ? cls : lookupChildGeneral(cls, node), prop);
    } catch (InvalidGrammarException e) {
      e.printStackTrace();
      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

   
    //System.err.println("(pass: " + pass + ")\n==\n");
    // Add the footer to each visit
    for (AGEval.Class cls : aleg.classes) {
      if (openLoopVars.containsKey(cls))
        throw new InvalidGrammarException("End of visit with unclosed loop: " + cls.getName()+"::"+openLoopVars.get(cls).get(0));
        //closeLoop(cls, sched, openLoopVars, visit, exprToCall, exprPrinter);
      visit.put(cls, visit.get(cls) + backend.visitFooter(cls, visitNum, sched._ast));     
    }
    return visit;
  }
View Full Code Here

    res += backend.openLastChild(cls, loopVar);
    boolean hasAnyToCopy = false;
    if (!openLoops.containsKey(cls)) {
      String options = "";
      for (AGEval.Class c : openLoops.keySet()) options += "option: " + c.getName() + "\n";
      throw new InvalidGrammarException("No loop to close on class " + cls.getName() + ":" + options);
    }
   
    for (String f : openLoops.get(cls)) {
      String cleanF = f.replace("_step", "").replace("_", "@");   
      //System.err.println("Checking for closure open var " + cleanF);
View Full Code Here

        if (visitOrder == null) {
          String available = "";
          for (AGEval.Class key : childOrders.keySet()) {
            available += key.getName().toLowerCase() + " ";
          }
          throw new InvalidGrammarException("No visit order for class " + cls.getName().toLowerCase() + ", available: " + available);
        }
       
        String childName = visitOrder.get(childI);
        if (childrenContains(sched._ast.extendedClasses.get(cls).multiChildren.keySet(), childName)) {
          boolean selfLoop = openLoopVars.get(cls) == null;
View Full Code Here

        //return;
      }
      for (String s : exprToCall.keySet()) {       
        System.err.println("  option: " + s);
      }
      throw new InvalidGrammarException("Could not find action for " + exprName);
   

   
    //close loop
    String origLhs = (vertex[0].toString().equals("self") ? "": (vertex[0].toString() + "@"))
    + (vertex[0].toString().equals("self") ?
          vertex[1].toString().replace("_step", "").replace("_last", "").replace("_", "@")
        : vertex[1].toString());
   
    String newLoopVar = schedule2._ast.extendedClasses.get(cls).idToLoop.get(origLhs);
    if (origLhs.contains("@init"))
      newLoopVar = "";
    if (newLoopVar == null)
      throw new InvalidGrammarException("could not find enclosing loop, if any: " + origLhs);
    if (vertex[1].toString().contains("_last")) {
      if (newLoopVar.equals(""))
        throw new InvalidGrammarException("last variable " + cls.getName()+"::"+origLhs + " not in loop");
      if (openLoopVars.get(cls) == null)
        return; //already closed
      else {
        if (openLoopVars.get(cls).size() == 0)
          throw new InvalidGrammarException("Closing open loop with nothing in it");
        String oldLoopVar = "";
        if (openLoopVars.containsKey(cls)) {
          for (String lhsRaw : openLoopVars.get(cls)) {
            String lhs = lhsRaw.toLowerCase();
            oldLoopVar = schedule2._ast.extendedClasses.get(cls).idToLoop.get(lhs.replace("_step", "").replaceFirst("_", "@"));
            break;
          }       
        }
        if (!oldLoopVar.equals(newLoopVar))
          throw new InvalidGrammarException("Wrong loop var on closing " + cls.getName() + "::" + origLhs);
        closeLoop(cls, oldLoopVar, schedule2, openLoopVars, visit, exprToCall, exprPrinter);
        return;
      }     
    } else {
      boolean inLoop = vertex[1].toString().contains("_step");
      if (inLoop) {
        if (openLoopVars.get(cls) != null) {
          if (openLoopVars.get(cls).size() == 0)
            throw new InvalidGrammarException("Continuing open loop that is empty on " + cls.getName()+ "::" + origLhs);
          String oldLoopVar = "";
          if (openLoopVars.containsKey(cls)) {
            for (String lhsRaw : openLoopVars.get(cls)) {
              String lhs = lhsRaw.toLowerCase();
              oldLoopVar = schedule2._ast.extendedClasses.get(cls).idToLoop.get(lhs.replace("_step", "").replaceFirst("_", "@"));
              break;
            }       
          }
          if (!oldLoopVar.equals(newLoopVar)) throw new InvalidGrammarException("Wrong loop var on continuing " + cls.getName() + "::" + origLhs);       
        } else {
          visit.put(cls, visit.get(cls) + openLoop(cls, openLoopVars));
        }
        openLoopVars.get(cls).add(lhsVertex);
      }
View Full Code Here

      if (isParent) {
        return fields.findClField(cls, cleanProp).getClRhsName() + "(index)";
      } else if (Generator.childrenContains(ast.extendedClasses.get(cls).multiChildren.keySet(), child)) {
        return fields.findClField(cls, child + "_" + cleanProp + "_last").getClRhsName() + "(index)";
      } else {
        throw new InvalidGrammarException("Cannot access $$ attrib of a non-multi child / self reduction: "
            + lhs);
      }
      // $i means access the current iteration of a loop
    } else if (prop.contains("$i")) { // We're working with a multi child
      if (isParent) {
        throw new InvalidGrammarException("Cannot access $i of self attrib: " + lhs);
      } else if (Generator.childrenContains(ast.extendedClasses.get(cls).multiChildren.keySet(), child)) {
        AGEval.IFace child_class = cls.getChildByName(child);
        return fields.findClField(child_class, cleanProp).getClRhsName() + "(current_node)";
      } else {
        throw new InvalidGrammarException("Cannot access $i attrib of a non-multi child: " + lhs);
      }
      // $- means access the previous iteration of the loop
    } else if (prop.contains("$-")) {
      if (isParent) {
        return fields.findClField(cls, cleanProp).getClRhsName() + "(index)";
      } else if (Generator.childrenContains(ast.extendedClasses.get(cls).multiChildren.keySet(), child)) {
        String name_last = child + "_" + cleanProp + "_last";
        String init = fields.findClField(cls, name_last).getClRhsName() + "(index)";
        String rest = fields.findClField(cls.getChildByName(child), cleanProp).getClRhsName() + "(PREV_OCL())";
        return "(STEP() == 1 ? (" + init + ") : (" + rest + "))";
      } else {
        throw new InvalidGrammarException("Cannot access $- attrib of a non-multi child: " + lhs);
      }
      // We're just working with regular variables
    } else {
      if (isParent) {
        Field fld = fields.findClField(cls, cleanProp);
        if (fld == null) {
          throw new InvalidGrammarException("Undeclared field identifier " + cleanProp + " in " + lhs);
        }
        return fields.findClField(cls, cleanProp).getClRhsName() + "(index)";
      } else if (ast.extendedClasses.get(cls).multiChildren.containsKey(child)) {
        return fields.findClField(cls.getChildByName(child), cleanProp).getClRhsName() + "(current_node)"; //CHECK: index?
      } else {
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.