Package AGEval

Examples of AGEval.InvalidGrammarException


      }

      ALEParser.ExtendedVertex ev = Generator.lookupAttributeExtended(arg, assign._class, ast);

      if (ev != null && ev.isMaybeType) {
        throw new InvalidGrammarException(
            "'maybe' types not currently implemented in Flat C++ backend. Yell at Matt.");
      } else {
        params.append(FlatCppFieldsHelper.typeStringToFlatCppType(Generator.extendedGet(ast, assign._class,
            arg).strType));
      }
View Full Code Here


      } else if (stencil.equals("td")) {
        contents.append(generateTopDownTraversal("visit_" + i));
      } else if (stencil.equals("bu")) {
        contents.append(generateBottomUpTraversal("visit_" + i));
      } else {
        throw new InvalidGrammarException("Unsupported traversal order: " + stencil);
      }
    }
    contents.append("}\n\n\n");

    return contents.toString();
View Full Code Here

              Integer.valueOf(""+ defS.charAt(3) + defS.charAt(4), 16) + ", " +
              Integer.valueOf(""+ defS.charAt(5) + defS.charAt(6), 16) + ", " +
              Integer.valueOf(""+ defS.charAt(7) + defS.charAt(8), 16) + ");\n";
            break;
          default:
            throw new InvalidGrammarException("Unknown default color " + defS + " for field " + prop);
          }                      
        } else if (propType.equals("taggedInt")) {
          String sub = v.maybeDefault.substring(1, v.maybeDefault.length() - 1);
          defVal = ", makeTaggedInt(" + sub + ")";
        } else if (propType.equals("taggedFloat")) {
          String sub = v.maybeDefault.substring(1, v.maybeDefault.length() - 1);
          defVal = ", makeTaggedFloat(" + sub + ")";
        } else {
          defVal = ", ExtraDataHandler::TOK_" + defS.toUpperCase();         
        }
      }

     
      if (v.maybeDefault != null && v.isMaybeType) throw new InvalidGrammarException("Cannot be a maybeType with a default value: property " + prop);
     
      String res = "data.genData." + base + ".fld_";
      String lookup = "lookupProp(properties, p.prop_" + CppParserGenerator.clean(prop) + ")";
      if (propType.equals("color")) {
        res += CppParserGenerator.clean(prop) + " = ";
View Full Code Here

      allClassReads.get(cls).add(cleanV);
      if (!loopVar.equals("") && (v.contains("$$") || v.contains("$i") || v.contains("$-"))) {
        if (AGEvaluatorSwipl.attribBase(v).equals("self")) {
          String oldLoop = allClassLoopListReads.get(cls).get(cleanVFull);
          if (oldLoop != null && !oldLoop.equals(loopVar))
            throw new InvalidGrammarException("loop self::" + v + " var used in two different loops: " + loopVar + " and " + oldLoop);         
        }
        if (v.contains("$i") || v.contains("$-")) //ignore $$
          allClassLoopListReads.get(cls).put(cleanVFull, loopVar);
        else if (!allClassLoopListReads.get(cls).containsKey(cleanVFull))
          allClassLoopListReads.get(cls).put(cleanVFull, null); //might be from another loop
View Full Code Here

      String stencil = visit.arg(2).arg(1).toString();
      if (stencil.equals("tdLtrU")) res += "  visit_" + pass + "(root); //inorder visitors handle recursion \n";       
      else if (stencil.equals("td")) res += "  inherit(visit_" + pass + ", root);\n";
      else if (stencil.equals("bu")) res += "  synthesize(visit_" + pass + ", root);\n";
      else if (stencil.equals("buSubInorder")) res += "  buSubInorder(visit_" + pass + ", root);\n";
      else throw new InvalidGrammarException("Unknown stencil type: " + stencil);
      pass++;     
    }     
    return res + "}\n";
  }
View Full Code Here

        if (isParent) {
          return "getAttribSafe(node, \"" + cleanProp + "\")";           
        } else if (Generator.childrenContains(ast.extendedClasses.get(cls).multiChildren.keySet(), child)) {
          return "getAttribSafe(node, \"" + child + "_" + cleanProp + "_last\")";           
        } else {
          throw new InvalidGrammarException("Cannot access $$ attrib of a non-multi child / self reduction: " + lhs);
        }
      } else if (prop.contains("$i")) {
        if (isParent) {
          //FIXME fine for reduction?...
          throw new InvalidGrammarException("Rhs: Cannot access $i of self attrib in class/interface " + cls.getName() + ": " + lhs);
          //return "getAttribSafe(node.getAttribute(\"" + cleanProp + "\"))";
        } else if (Generator.childrenContains(ast.extendedClasses.get(cls).multiChildren.keySet(), child)) {
          String maybeD = getInputDefaultMaybe(cls.getChildByName(child), cleanProp, ast);
          if (maybeD == null) {
            ALEParser.ExtendedVertex ev = Generator.lookupAttributeExtended(child + "@" + cleanProp, cls, ast);   
            return (ev != null && ev.isMaybeType) ?
                ("getInputMaybeAttribSafe(child, \"" + cleanProp + "\")")
                : ("getAttribSafe(child, \"" + cleanProp + "\")");
          } else return "getInputAttribSafe(child, \"" + cleanProp + "\", " + maybeD + ")";         
        } else {
          throw new InvalidGrammarException("Cannot access $i attrib of a non-multi child: " + lhs);
          //return "getAttribSafe(getChildByRefName(node,\"" + child + "\").getAttribute(\"" + cleanProp + "\"))"; 
        }         
      } else if (prop.contains("$-")) {
        if (isParent) {
          return "getAttribSafe(node, \"" + cleanProp + "\")";
              //cleanProp + "_last"; //FIXME check acc assign happens last 
        } else if (Generator.childrenContains(ast.extendedClasses.get(cls).multiChildren.keySet(), child)) {
          return "getAttribSafe(i == 0 ? node : children[i-1], i == 0 ? (\"" + child.toLowerCase() + "_" + cleanProp + "_init\") : (\"" + cleanProp + "\"))";             
        } else {
          throw new InvalidGrammarException("Cannot access $- attrib of a non-multi child: " + lhs);
        }
      } else if (prop.contains("[-1]"))  {
        if (isParent) {
          throw new InvalidGrammarException("cannot use [-1] on a self attrib: " + lhs)
        } else if (Generator.childrenContains(ast.extendedClasses.get(cls).multiChildren.keySet(), child)) {
          return "getAttribSafe(node, (\"" + child.toLowerCase() + "_" + cleanProp + "_init\"))";             
        } else {
          throw new InvalidGrammarException("Cannot access $- attrib of a non-multi child: " + lhs);
        }
       
      } else {
        if (isParent) {         
          String maybeD = getInputDefaultMaybe(cls, cleanProp, ast);
          if (maybeD == null) {
            ALEParser.ExtendedVertex ev = Generator.lookupAttributeExtended(prop, cls, ast);   
            return (ev != null && ev.isMaybeType) ?
                ("getInputMaybeAttribSafe(node, \"" + cleanProp + "\")") :
                ("getAttribSafe(node, \"" + cleanProp+ "\")");
          }
          else return "getInputAttribSafe(node, \"" + cleanProp + "\", " + maybeD + ")";         
        } else if (Generator.childrenContains(ast.extendedClasses.get(cls).multiChildren.keySet(), child)) {
          //throw new InvalidGrammarException("Cannot read multichild attrib without indexer ($-, ...): " + cls.getName() + "::?? := ... " + lhs);
          //FIXME currently allowed because logging might read back on "loop ... { ... child.x := ... }"
          String maybeD = getInputDefaultMaybe(cls.getChildByName(child), cleanProp, ast);
         
          try {
            if (maybeD == null) {
              ALEParser.ExtendedVertex ev = Generator.lookupAttributeExtended(child + "@" + cleanProp, cls, ast);   
              return (ev != null && ev.isMaybeType) ?
                  ("getInputMaybeAttribSafe(child, \"" + cleanProp + "\")") :
                  ("getAttribSafe(child, \"" + cleanProp + "\")");
            } else return "getInputAttribSafe(child, \"" + cleanProp + "\", " + maybeD + ")";
          } catch (InvalidGrammarException e) {
            throw new InvalidGrammarException("rhs val fail ( " + cls.getName() + "): " + lhs + " => " + prop + " => " + cleanProp + ", " + maybeD + "\n"
                + e.getMessage());
          }
         
        } else {
          String maybeD = getInputDefaultMaybe(cls.getChildByName(child), cleanProp, ast);
View Full Code Here

    String res = "";
    if (c.isAtom()) {     
      res += "<atom>";
      if (!whitelist.contains(c.name()) && !tokens.contains(c.name())) {
        System.err.println("Tokens: " + tokens);
        throw new InvalidGrammarException("Schedule sanitization failed; could not match atom '"+ c.name() + "' in whitelist (term '" + c.toString() + "')")
      }
    } else  if (c.isCompound()) {
      res += "<compound '" + c.name()+"'>(";
      if (!whitelist.contains(c.name())) {
        throw new InvalidGrammarException("Schedule sanitization failed; could not match compound operator '"+ c.name() + "' in whitelist (term '" + c.toString() + "')");
      }
      for (int i = 0; i < c.arity(); i++) {
        if (i > 0) res += ", ";
        res += recoverQuery(c.arg(i+1));
      }
      res += ")";
    } else if (c.isFloat()) {
      res += "<float>";
    } else if (c.isInteger()) {
      res += "<int>";
    } else if (c.isVariable()) {
      res += "<var>";
    } else {
      throw new InvalidGrammarException("Schedule sanitization failed; could not parse Prolog schedule term " + c.toString());
    }
    return res; 
  }
View Full Code Here

      System.err.println(new_field.getCppName() + " is a maybe type");
    }
   
    // TODO: Add support for 'maybe' types
    if(new_field.isMaybeType()) {
      throw new InvalidGrammarException("'maybe' types are not yet implemented in the Flat C++ backend. Go yell at Matt.");
    }
   
    return new_field;
  }
View Full Code Here

        assignedNotAsReduce |= !stmt.isReduction;
        if (assignedAsReduce && assignedNotAsReduce) break;
      }
    }   
    if (assignedNotAsReduce) {
      throw new InvalidGrammarException("Use of " + v + " in assignment to " + asgn._class.getName() + "::" + asgn._sink + " illegal: not all definitions of " + cleanV + " are reductions");
    } else if (!assignedAsReduce) {
      throw new InvalidGrammarException("Use of " + v + " in assignment to " + asgn._class.getName() + "::" + asgn._sink + " illegal: no local reduction definition of " + cleanV + "");
   
  }
View Full Code Here

  */
 
  public static AGEval.IFace getIFaceByEc(ALEParser ast, ExtendedClass ec) throws InvalidGrammarException {
    for (Entry<AGEval.IFace, ExtendedClass> e : ast.extendedClasses.entrySet())
      if (e.getValue() == ec) return e.getKey();
    throw new InvalidGrammarException("Cannot find name for ec");
  }
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.