Examples of ErrorSyntax


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

            List<Object> seenDollar = new ArrayList<Object>();
            CompModule root = parseRecursively(seenDollar, loaded, fc, new Pos(filename,1,1), filename, null, "", thispath, initialResolutionMode);
            root.seenDollar = seenDollar.size()>0;
            return CompModule.resolveAll(rep==null ? A4Reporter.NOP : rep, root);
        } catch(FileNotFoundException ex) {
            throw new ErrorSyntax("File cannot be found.\n"+ex.getMessage(), ex);
        } catch(IOException ex) {
            throw new ErrorFatal("IOException occurred: "+ex.getMessage(), ex);
        } catch(Throwable ex) {
            if (ex instanceof Err) throw (Err)ex; else throw new ErrorFatal("Unknown exception occurred: "+ex, ex);
        }
View Full Code Here

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

      this.isSome     = isSome;
      this.isSubset   = isSubset;
      this.isSubsig   = isSubsig;
      this.label      = label;
      this.builtin    = false;
      if (isLone!=null && isOne!=nullthrow new ErrorSyntax(isLone.merge(isOne)"You cannot declare a sig to be both lone and one.");
      if (isLone!=null && isSome!=null) throw new ErrorSyntax(isLone.merge(isSome), "You cannot declare a sig to be both lone and some.");
      if (isOne!=null  && isSome!=null) throw new ErrorSyntax(isOne.merge(isSome)"You cannot declare a sig to be both one and some.");
      if (isSubset!=null && isAbstract!=null) throw new ErrorSyntax(isAbstract,  "Subset signature cannot be abstract.");
      if (isSubset!=null && isSubsig!=null)   throw new ErrorSyntax(isAbstract,  "Subset signature cannot be a regular subsignature.");
   }
View Full Code Here

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

       * @throws ErrorSyntax if the signature has two or more multiplicities
       * @throws ErrorType if you attempt to extend the builtin sigs NONE, SIGINT, SEQIDX, or STRING
       */
      public PrimSig (String label, PrimSig parent, Attr... attributes) throws Err {
         super(((parent!=null && parent.isEnum!=null) ? parent.type : null), label, Util.append(attributes, Attr.SUBSIG));
         if (parent==SIGINT) throw new ErrorSyntax(pos, "sig "+label+" cannot extend the builtin \"Int\" signature");
         if (parent==SEQIDX) throw new ErrorSyntax(pos, "sig "+label+" cannot extend the builtin \"seq/Int\" signature");
         if (parent==STRING) throw new ErrorSyntax(pos, "sig "+label+" cannot extend the builtin \"String\" signature");
         if (parent==NONE)   throw new ErrorSyntax(pos, "sig "+label+" cannot extend the builtin \"none\" signature");
         if (parent==null) parent=UNIV; else if (parent!=UNIV) parent.children.add(this);
         this.parent = parent;
         if (isEnum!=null && parent!=UNIV) throw new ErrorType(pos, "sig "+label+" is not a toplevel sig, so it cannot be an enum.");
         for( ; parent!=null ; parent=parent.parent) if (parent.isEnum!=null) {
            if (parent!=this.parent) throw new ErrorSyntax(pos, "sig "+label+" cannot extend a signature which is an atom in an enum.");
            if (isOne==null) throw new ErrorSyntax(pos, "sig "+label+" is an atom in an enum, so it must have the \"one\" multiplicity.");
         }
      }
View Full Code Here

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

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

      /** 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

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

            // 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

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

   /** 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

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

        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

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

   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

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

   /** 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
TOP
Copyright © 2018 www.massapi.com. 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.