Package edu.mit.csail.sdg.alloy4

Examples of edu.mit.csail.sdg.alloy4.ErrorSyntax


         if (parents==null || parents.size()==0) {
            temp.add(UNIV);
         } else {
            for(Sig parent:parents) {
               if (!Version.experimental) {
                  if (parent==SIGINT) throw new ErrorSyntax(pos, "sig "+label+" cannot be a subset of the builtin \"Int\" signature");
                  if (parent==SEQIDX) throw new ErrorSyntax(pos, "sig "+label+" cannot be a subset of the builtin \"seq/Int\" signature");
                  if (parent==STRING) throw new ErrorSyntax(pos, "sig "+label+" cannot be a subset of the builtin \"String\" signature");
               }
               if (parent==Sig.UNIV) {temp.clear(); temp.add(UNIV); break;}
               if (parent!=Sig.NONE && !temp.contains(parent)) temp.add(parent);
            }
         }
View Full Code Here


      /** Constructs a new Field object. */
      private Field(Pos pos, Pos isPrivate, Pos isMeta, Pos disjoint, Pos disjoint2, Sig sig, String label, Expr bound) throws Err {
         super(pos, label, sig.type.product(bound.type));
         this.defined = bound.mult() == ExprUnary.Op.EXACTLYOF;
         if (sig.builtin) throw new ErrorSyntax(pos, "Builtin sig \""+sig+"\" cannot have fields.");
         if (!bound.errors.isEmpty()) throw bound.errors.pick();
         if (!this.defined && bound.hasCall()) throw new ErrorSyntax(pos, "Field \""+label+"\" declaration cannot contain a function or predicate call.");
         if (bound.type.arity()>0 && bound.type.hasNoTuple()) throw new ErrorType(pos, "Cannot bind field "+label+" to the empty set or empty relation.");
         this.isPrivate = (isPrivate!=null ? isPrivate : sig.isPrivate);
         this.isMeta = (isMeta!=null ? isMeta : sig.isMeta);
         this.sig = sig;
      }
View Full Code Here

            // If the parser is really really confused, alloy_confirm() could fail with array out-of-bound exception, etc.
        }
    }
    String result="There are "+list.size()+" possible tokens that can appear here:\n";
    for(String item:list) result=result+item+" ";
    throw new ErrorSyntax(p, (list.size()!=0)?result:"");
  }
View Full Code Here

   /** Parse the file into an AlloyInstance if possible. */
   private StaticInstanceReader(XMLNode root) throws Err {
      XMLNode inst = null;
      for(XMLNode sub: root) if (sub.is("instance")) { inst=sub; break; }
      if (inst==null) throw new ErrorSyntax("The XML file must contain an <instance> element.");
      boolean isMeta = "yes".equals(inst.getAttribute("metamodel"));
      A4Solution sol = A4SolutionReader.read(new ArrayList<Sig>(), root);
      for (Sig s:sol.getAllReachableSigs()) if (s instanceof PrimSig && ((PrimSig)s).parent==Sig.UNIV) toplevels.add((PrimSig)s);
      if (!isMeta) {
         sig2type.put(Sig.UNIV, AlloyType.UNIV);
View Full Code Here

        if (body.type().arity()<0 || body.type().arity()!=f.returnDecl.type().arity()) throw new ErrorType(body.span(), "Function return value not fully resolved.");
        final int n = f.count();
        int maxRecursion = unrolls;
        for(Func ff:current_function) if (ff==f) {
            if (maxRecursion<0) {
                throw new ErrorSyntax(x.span(), ""+f+" cannot call itself recursively!");
            }
            if (maxRecursion==0) {
                Type t = f.returnDecl.type();
                if (t.is_bool) return Formula.FALSE;
                if (t.is_int) return IntConstant.constant(0);
View Full Code Here

   static ErrorSyntax hint (Pos pos, String name) {
      String msg="The name \""+name+"\" cannot be found.";
      if ("exh".equals(name) || "exhaustive".equals(name) || "part".equals(name) || "partition".equals(name))
         msg=msg+" If you are migrating from Alloy 3, please see Help->QuickGuide on how to translate models that use the \""
         +name+"\" keyword.";
      return new ErrorSyntax(pos, msg);
   }
View Full Code Here

   /** Parse one expression by starting fromt this module as the root module. */
   public Expr parseOneExpressionFromString(String input) throws Err, FileNotFoundException, IOException {
      Map<String,String> fc = new LinkedHashMap<String,String>();
      fc.put("", "run {\n"+input+"}"); // We prepend the line "run{"
      CompModule m = CompParser.alloy_parseStream(new ArrayList<Object>(), null, fc, null, -1, "", "", 1);
      if (m.funcs.size()==0) throw new ErrorSyntax("The input does not correspond to an Alloy expression.");
      Expr body = m.funcs.values().iterator().next().get(0).getBody();
      Context cx = new Context(this, null);
      body = cx.check(body);
      body = body.resolve(body.type(), null);
      if (body.errors.size()>0) throw body.errors.pick(); else return body;
View Full Code Here

      if (body.errors.size()>0) throw body.errors.pick(); else return body;
   }

   /** Throw an exception if the name is already used, or has @ or /, or is univ/Int/none. */
   private void dup(Pos pos, String name, boolean checkSig) throws Err {
      if (name.length()==0)     throw new ErrorSyntax(pos, "Name cannot be empty");
      if (name.indexOf('@')>=0) throw new ErrorSyntax(pos, "Name cannot contain the \'@\' character");
      if (name.indexOf('/')>=0) throw new ErrorSyntax(pos, "Name cannot contain the \'/\' character");
      if (name.equals("univ"))  throw new ErrorSyntax(pos, "\'univ\' is a reserved keyword.");
      if (name.equals("Int"))   throw new ErrorSyntax(pos, "\'Int\' is a reserved keyword.");
      if (name.equals("none"))  throw new ErrorSyntax(pos, "\'none\' is a reserved keyword.");
      if (checkSig && (params.containsKey(name) || sigs.containsKey(name)))
         throw new ErrorSyntax(pos, "\""+name+"\" is already the name of a sig/parameter in this module.");
   }
View Full Code Here

         else if (x instanceof Expr) {
            Expr y = (Expr)x;
            msg.append("assertion at ").append(y.pos.toShortString());
         }
      }
      throw new ErrorSyntax(pos, msg.toString());
   }
View Full Code Here

   /** Returns an unmodifiable copy of the current list of OPEN statements. */
   public ConstList<Open> getOpens() { return ConstList.make(opens.values()); }

   /** Add the "MODULE" declaration. */
   void addModelName(Pos pos, String moduleName, List<ExprVar> list) throws Err {
      if (status>0) throw new ErrorSyntax(pos,
            "The \"module\" declaration must occur at the top,\n" + "and can occur at most once.");
      this.moduleName = moduleName;
      this.modulePos = pos;
      boolean nextIsExact = false;
      if (list!=null) for(ExprVar expr: list) {
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4.ErrorSyntax

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.