//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);
}