Package edu.mit.csail.sdg.alloy4

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


      final List<Decl> oldDecls = res.old2fields.get(res.new2old.get(s));
      if (oldDecls==null) return;
      final CompModule m = res.sig2module.get(s);
      final Context cx = new Context(m, warns);
      final ExprHasName dup = Decl.findDuplicateName(oldDecls);
      if (dup!=null) throw new ErrorSyntax(dup.span(), "sig \""+s+"\" cannot have 2 fields named \""+dup.label+"\"");
      for(final Decl d: oldDecls) {
         if (d.expr.mult()!=ExprUnary.Op.EXACTLYOF) {if (defined) continue;} else {if (!defined) continue;}
         // The name "this" does matter, since the parser and the typechecker both refer to it as "this"
         cx.rootfield = d;
         cx.rootsig = s;
View Full Code Here


     * @param unrolls - the maximum number of loop unrolling and recursion allowed
     * @param a2k - the mapping from Alloy sig/field/skolem/atom to the corresponding Kodkod expression
     */
    private TranslateAlloyToKodkod (int bitwidth, int unrolls, Map<Expr,Expression> a2k, Map<String,Expression> s2k) throws Err {
        this.unrolls = unrolls;
        if (bitwidth<1throw new ErrorSyntax("Cannot specify a bitwidth less than 1");
        if (bitwidth>30) throw new ErrorSyntax("Cannot specify a bitwidth greater than 30");
        this.rep = A4Reporter.NOP;
        this.cmd = null;
        this.frame = null;
        this.bitwidth = bitwidth;
        this.max = (1<<(bitwidth-1)) - 1;
View Full Code Here

        }
    }

    /** Construct a new simulation context with the given bitwidth and the given maximum sequence length. */
    public SimInstance(Module root, int bitwidth, int maxseq) throws Err {
        if (bitwidth<1 || bitwidth>32) throw new ErrorType("Bitwidth must be between 1 and 32.");
        this.root = root;
        this.bitwidth = bitwidth;
        this.maxseq = maxseq;
        this.callbacks = new HashMap<Func,SimCallback>();
        if (bitwidth==32) { max=Integer.MAX_VALUE; min=Integer.MIN_VALUE; } else { max=(1<<(bitwidth-1))-1; min=(0-max)-1; }
View Full Code Here

    /** Initializes the given sig to be associated with the given unary value; should only be called at the beginning.
     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(Sig sig, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(sig); return; }
        if (value.arity()>1) throw new ErrorType("Evaluator encountered an error: sig "+sig.label+" arity must not be " + value.arity());
        if (sig.builtin) throw new ErrorAPI("Evaluator cannot prebind the builtin sig \"" + sig.label + "\"");
        sfs.put(sig, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
View Full Code Here

    /** Initializes the given field to be associated with the given unary value; should only be called at the beginning.
     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(Field field, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(field); return; }
        if (!value.empty() && value.arity()!=field.type().arity()) throw new ErrorType("Evaluator encountered an error: field "+field.label+" arity must not be " + value.arity());
        if (field.defined) throw new ErrorAPI("Evaluator cannot prebind the value of a defined field.");
        sfs.put(field, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
View Full Code Here

    /** Initializes the given var to be associated with the given unary value; should only be called at the beginning.
     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(ExprVar var, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(var); return; }
        if (!value.empty() && value.arity()!=var.type().arity()) throw new ErrorType("Evaluator encountered an error: skolem "+var.label+" arity must not be " + value.arity());
        sfs.put(var, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
    }
View Full Code Here

        final Func f = x.fun;
        final int n = f.count();
        final Object candidate = n==0 ? cacheForConstants.get(f) : null;
        if (candidate!=null) return candidate;
        final Expr body = f.getBody();
        if (body.type().arity()<0 || body.type().arity()!=f.returnDecl.type().arity()) throw new ErrorType(body.span(), "Function return value not fully resolved.");
        for(Func ff:current_function) if (ff==f) throw new ErrorSyntax(x.span(), ""+f+" cannot call itself recursively!");
        Env<ExprVar,Object> newenv = new Env<ExprVar,Object>();
        List<SimTupleset> list = new ArrayList<SimTupleset>(x.args.size());
        for(int i=0; i<n; i++) { SimTupleset ts = cset(x.args.get(i)); newenv.put(f.get(i), ts);  list.add(ts); }
        final SimCallback cb = callbacks.get(f);
View Full Code Here

    /** {@inheritDoc} */
    @Override public Object visit(ExprConstant x) throws Err {
        switch(x.op) {
          case NUMBER:
             int n = x.num();
             if (n<min) throw new ErrorType(x.pos, "Current bitwidth is set to "+bitwidth+", thus this integer constant "+n+" is smaller than the minimum integer "+min);
             if (n>max) throw new ErrorType(x.pos, "Current bitwidth is set to "+bitwidth+", thus this integer constant "+n+" is bigger than the maximum integer "+max);
             return n;
          case FALSE: return Boolean.FALSE;
          case TRUE: return Boolean.TRUE;
          case MIN: return min;
          case MAX: return max;
View Full Code Here

   Expr (Pos pos, Pos closingBracket, boolean ambiguous, Type type, int mult, long weight, JoinableList<Err> errors) {
      this.pos = (pos==null ? Pos.UNKNOWN : pos);
      this.closingBracket = (closingBracket==null ? Pos.UNKNOWN : closingBracket);
      this.ambiguous      = ambiguous;
      if (errors==null) errors = emptyListOfErrors;
      if (type==EMPTY && errors.size()==0) errors = errors.make(new ErrorType(pos, "This expression failed to be typechecked"));
      this.mult   = (mult<0 || mult>2) ? 0 : mult;
      this.type   = (errors.size()>0 || type==null) ? EMPTY : type;
      this.weight = (weight>0) ? weight : 0;
      this.errors = errors;
   }
View Full Code Here

   /** Converts this into a "formula" if possible; otherwise, returns an Expr with a nonempty error list */
   public final Expr typecheck_as_formula() {
      if (!errors.isEmpty() || type.is_bool) return this;
      String msg = "This must be a formula expression.\nInstead, it has the following possible type(s):\n" + type;
      return NOOP.make(null, this, new ErrorType(span(), msg), 0);
   }
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.