Package AGEval

Examples of AGEval.InvalidGrammarException


    //  c.x => c.x -> x_step0
    for (String v : variables.keySet()) {
      if (v.contains("$i")) {                   
        if (attribBase(v).toLowerCase().equals(attribBase(asgn._sink).toLowerCase())
            && attribName(v.replace("$i", "")).toLowerCase().equals(attribName(asgn._sink).toLowerCase()))
          throw new InvalidGrammarException("<x> = fold <e> .. ... <x>$i ...) on " + asgn._class.getName()+"::" + asgn._sink); //FIXME this should be a syntax check
        String vClean = v.replace("$i", "");
        res += "assignment(" + asgn._class.getName().toLowerCase() + ", "
          + "self, "
          + (attribBase(asgn._sink).equals("self") ? "": (attribBase(asgn._sink).toLowerCase() + "_") ) + attribName(asgn._sink).toLowerCase()+"_step0" + ", "
          + "self, "
View Full Code Here


      //    v => v -> x_step0
      //    v$$ => v_stepn -> x_step0
      //    c.x => c.x -> x_step0
      for (String v : asgn.startVariables.keySet()) {
        if (v.contains("$i") || v.contains("$-"))
          throw new InvalidGrammarException("Initialization of " + asgn._class.getName()+"::"+asgn._sink + " reads non-initial variable" + v);
        if (!attribBase(v).equals("self") && Generator.childrenContains(ast.extendedClasses.get(asgn._class).multiChildren.keySet(), attribBase(v)))
          throw new InvalidGrammarException("Initialization of " + asgn._class.getName()+"::"+asgn._sink + " reads children variable" + v);
 
        if (v.contains("$$")) {
          checkReducible(asgn, v, ast, reducts);
          res += "assignment(" + asgn._class.getName().toLowerCase() + ", "
            + "self, " + (attribBase(asgn._sink).equals("self") ? "": (attribBase(asgn._sink).toLowerCase() + "_") ) + attribName(asgn._sink).toLowerCase()+"_step0" + ", "
            + "self, " + (attribBase(v).toLowerCase().equals("self") ? "" : (attribBase(v).toLowerCase() + "_")) + attribName(v).toLowerCase().replace("$$", "") + "_stepn). %a17\n";         
        } else {         
          res += "assignment(" + asgn._class.getName().toLowerCase() + ", "
            + "self, " + (attribBase(asgn._sink).equals("self") ? "": (attribBase(asgn._sink).toLowerCase() + "_") ) + attribName(asgn._sink).toLowerCase()+"_step0" + ", "
            + attribBase(v).toLowerCase() + ", " + attribName(v).toLowerCase() + "). %a18\n";           
        }
      }     
     
      res += addLoopAsgnBody(asgn.stepVariables, asgn, ast, reducts);
     
      return res;
     
    } else {
   
     
      String res = "";
      //x = e_0 ..
      //  v => v -> x_step
      //  $i, $-, children*.x => error
      //  v$$ => v_last -> x_step
      //  non-multi => non-multi
      for (String v : asgn.startVariables.keySet()) {
        if (v.contains("$i") || v.contains("$-"))
          throw new InvalidGrammarException("Initialization of " + asgn._class.getName()+"::"+asgn._sink + " reads non-initial variable" + v);
        if (!attribBase(v).equals("self") && Generator.childrenContains(ast.extendedClasses.get(asgn._class).multiChildren.keySet(), attribBase(v)))
          throw new InvalidGrammarException("Initialization of " + asgn._class.getName()+"::"+asgn._sink + " reads children variable" + v);
 
        if (v.contains("$$")) {
          checkReducible(asgn, v, ast, reducts);
          res += "assignment(" + asgn._class.getName().toLowerCase() + ", "
            + "self, " + (attribBase(asgn._sink).equals("self") ? "": (attribBase(asgn._sink).toLowerCase() + "_") ) + attribName(asgn._sink).toLowerCase()+"_step" + ", "
View Full Code Here

          if (v.contains("$-")) {
            for (Assignment vAsgn: reducts.allLoopStatements) {
              if (vAsgn._class != asgn._class) continue;
              if (!attribBase(vAsgn._sink).equals(attribBase(v)) || !attribName(vAsgn._sink).equals(attribName(vClean))) continue;
              if (!vAsgn.isReduction) {
                throw new InvalidGrammarException("Step of " + asgn._class.getName()+"::"+asgn._sink + " reads prev variable " + v + " which does not always exist for first step");
              }
            }
          }
          res += "assignment(" + asgn._class.getName().toLowerCase() + ", "
            + lhs
View Full Code Here

 
  public static String addLoopAsgn (ALEParser.Assignment asgn, ALEParser ast, Reductions reducts) throws InvalidGrammarException {
    String res = "";

    if (asgn.isReduction) res = addLoopAsgnReduction(asgn, ast, reducts);
    else if (asgn._sink.contains("[-1]")) { throw new InvalidGrammarException("No orthogonal init support yet"); }     
    else res = addLoopAsgnAsgn(asgn, ast, reducts);

    if (chainLoops) {
      //step0 -> step1 -> stepn
      res += chain(asgn._class, asgn._sink);
View Full Code Here

      if (!asgn.loopVar.equals("")) {       
        if (asgn.isReduction) {
          for (String e : asgn.startVariables.keySet())
            if (attribBase(e).equals("self") && (e.contains("$i") || e.contains("$-")))              
              if (!(attribBase(asgn._sink).equals("self") && attribName(asgn._sink).equals(attribName(e).replace("$i", "").replace("$-", "")))) {
                throw new InvalidGrammarException(asgn._class.getName() + "::" + asgn._sink + ": reads fold step " + e + "; can only access $$");
              }
          for (String e : asgn.stepVariables.keySet())
            if (attribBase(e).equals("self") && (e.contains("$i") || e.contains("$-")))              
              if (!(attribBase(asgn._sink).equals("self") && attribName(asgn._sink).equals(attribName(e).replace("$i", "").replace("$-", "")))) {
                throw new InvalidGrammarException(asgn._class.getName() + "::" + asgn._sink + ": reads fold step " + e + "; can only access $$");
              }
        } else {
          for (String e : asgn._variables.keySet())
            if (attribBase(e).equals("self") && (e.contains("$i") || e.contains("$-")))              
              if (!(attribBase(asgn._sink).equals("self") && attribName(asgn._sink).equals(attribName(e).replace("$i", "").replace("$-", "")))) {
                throw new InvalidGrammarException(asgn._class.getName() + "::" + asgn._sink + ": reads fold step " + e + "; can only access $$");
              }         
        }
      }
    }
    //2. self loops are reducibles  ( loop child { x = y$$ } is not allowed )
    for (Assignment asgn : ast.assignments) {
      if (!asgn.isReduction && !asgn.loopVar.equals("") && attribBase(asgn._sink).equals("self")) {
        System.err.println("loop " + asgn.loopVar + " { ... " + asgn._class + "::" + asgn._sink + " := <expr>");
        throw new InvalidGrammarException("Loop assignments to a self variable must be in a fold (or hoisted out of the loop)");
      }
    }
   
   
  }
View Full Code Here

    for (AGEval.Class c : aleg.classes)  {
      //simple assignments
      if (chainLoopsChilds) {
        for (Assignment a : ast.assignments) {
          if (a._class == c && a.loopVar.equals("")) {
            if (a.isReduction) throw new InvalidGrammarException("Reduction in non-loop!");
            if (a._variables.size() == 0) {           
              String asgn = "assignment(" + c.getName().toLowerCase() + ", "
                  + attribBase(a._sink).toLowerCase() + ", " + attribName(a._sink).toLowerCase() + ", "
                  + "self, " + fakeAttribute + "). %a40\n"; //force scheduling of nullary    
                res += asgn;
 
            } else {
              for (String src : a._variables.keySet()) {
                if (src.contains("$$")) {
                  boolean isChild = !attribBase(src).toLowerCase().equals("self");
                  res += "assignment(" + c.getName().toLowerCase() + ", "
                    + attribBase(a._sink).toLowerCase() + ", " + attribName(a._sink).toLowerCase() + ", "
                    + "self, " + (isChild ? attribBase(src).toLowerCase() + "_" : "") + attribName(src.replace("$$", "_stepn")).toLowerCase() + "). %a41\n"; //change to _last?
                } else {
                  res += "assignment(" + c.getName().toLowerCase() + ", "
                      + attribBase(a._sink).toLowerCase() + ", " + attribName(a._sink).toLowerCase() + ", "
                      + attribBase(src).toLowerCase() + ", " + attribName(src).toLowerCase() + "). %a42\n";                        
                }
              }
            }
          }
        }
      } else {
        for (AGEval.Function func : c.getFunctions()) {        
          for (String src : func.getStringSrcs()) {
            String asgn = "assignment(" + c.getName().toLowerCase() + ", "
              + attribBase(func.myDest).toLowerCase() + ", " + func.getDestination().getExtVar().toLowerCase() + ", "
              + attribBase(src).toLowerCase() + ", " + attribName(src).toLowerCase() + "). %a43\n";    
            res += asgn;
          }
          if (func.getStringSrcs().length == 0) {
            String asgn = "assignment(" + c.getName().toLowerCase() + ", "
              + attribBase(func.myDest).toLowerCase() + ", " + func.getDestination().getExtVar().toLowerCase() + ", "
              + "self, " + fakeAttribute + "). %a44\n"; //force scheduling of nullary    
            res += asgn;
          }
          hasAs = true;
        }
      }
      //conds
      if (ast.condsTop.containsKey(c)) {
        for (Cond cond : ast.condsTop.get(c)) {
          res += condAssignments(genSym.fake(), c, cond, genSym, reducts);
          throw new InvalidGrammarException("Deprecated: conditionals");       
        }
      }
      //loop assignments
      for (ALEParser.Assignment asgn : ast.assignments)
        if (asgn._class == c && !"".equals(asgn.loopVar))
View Full Code Here

         classMap.put(cls.getName().toLowerCase(), cls);
      }       
     
     
      if (!schedules.hasSolution()) { 
        throw new InvalidGrammarException("no solutions: " + new AGDebugger(AGEvaluatorSwipl.this).getError());
      }   
     
    }
View Full Code Here

     
      HashMap<AGEval.Class, ArrayList<String>> visitOrders = new HashMap<AGEval.Class, ArrayList<String> >(cTable.size());
      for (Term childOrder : binding.get("O").toTermArray()) {
        AGEval.Class c = cTable.get(childOrder.arg(1).toString());
        if (c == null) {
          throw new InvalidGrammarException("computeVisitOrders: Could not find: " + childOrder.arg(1));         
        }
        if (childOrder.arg(2).listLength() > 0) {
          ArrayList<String> visitOrder = new ArrayList<String>();
          for (Term child : childOrder.arg(2).toTermArray())
            visitOrder.add(child.toString());
View Full Code Here

   
    for (Entry<String, ALEParser.ExtendedVertex> e : ast.extendedClasses.get(cls).extendedVertices.entrySet())
      if (e.getKey().toLowerCase().equals(uProp)) return e.getValue();   

    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())
        if (e.getKey().toLowerCase().equals(uProp)) return e.getValue();   
   
    throw new InvalidGrammarException("Extended get on class fail: " + cls.getName() + " for " + prop)
  }
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

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.