Examples of ErrorSyntax


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

        return (y==null) ? (-1) : y;
    }

    /** Sets the scope for a sig; returns true iff the sig's scope is changed by this call. */
    private void sig2scope(Sig sig, int newValue) throws Err {
        if (sig.builtin)                throw new ErrorSyntax(cmd.pos, "Cannot specify a scope for the builtin signature \""+sig+"\"");
        if (!(sig instanceof PrimSig))  throw new ErrorSyntax(cmd.pos, "Cannot specify a scope for a subset signature \""+sig+"\"");
        if (newValue<0)                 throw new ErrorSyntax(cmd.pos, "Cannot specify a negative scope for sig \""+sig+"\"");
        int old=sig2scope(sig);
        if (old==newValue) return;
        if (old>=0)        throw new ErrorSyntax(cmd.pos, "Sig \""+sig+"\" already has a scope of "+old+", so we cannot set it to be "+newValue);
        sig2scope.put((PrimSig)sig, newValue);
        rep.scope("Sig "+sig+" scope <= "+newValue+"\n");
    }
View Full Code Here

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

        return sig==SIGINT || sig==SEQIDX || sig==STRING || ((sig instanceof PrimSig) && exact.containsKey(sig));
    }

    /** Make the given sig "exact". */
    private void makeExact(Pos pos, Sig sig) throws Err {
        if (!(sig instanceof PrimSig)) throw new ErrorSyntax(pos, "Cannot specify a scope for a subset signature \""+sig+"\"");
        exact.put(sig, sig);
    }
View Full Code Here

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

        exact.put(sig, sig);
    }

    /** Modifies the integer bitwidth of this solution's model (and sets the max sequence length to 0) */
    private void setBitwidth(Pos pos, int newBitwidth) throws ErrorAPI, ErrorSyntax {
        if (newBitwidth<1throw new ErrorSyntax(pos, "Cannot specify a bitwidth less than 1");
        if (newBitwidth>30) throw new ErrorSyntax(pos, "Cannot specify a bitwidth greater than 30");
        bitwidth = newBitwidth;
        maxseq = 0;
        sig2scope.put(SIGINT, 1<<bitwidth);
        sig2scope.put(SEQIDX, 0);
    }
View Full Code Here

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

        sig2scope.put(SEQIDX, 0);
    }

    /** Modifies the maximum sequence length. */
    private void setMaxSeq(Pos pos, int newMaxSeq) throws ErrorAPI, ErrorSyntax {
        if (newMaxSeq < 0)     throw new ErrorSyntax(pos, "The maximum sequence length cannot be negative.");
        if (newMaxSeq > max()) throw new ErrorSyntax(pos, "With integer bitwidth of "+bitwidth+", you cannot have sequence length longer than "+max());
        maxseq = newMaxSeq;
        sig2scope.put(SEQIDX, maxseq);
    }
View Full Code Here

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

          int sum=0;
          for(Sig c:subs) {
             int cn = sig2scope(c);
             if (cn<0) { if (missing==null) { missing=c; continue; } else { continue again; } }
             sum=sum+cn;
             if (sum<0) throw new ErrorSyntax(cmd.pos, "The number of atoms exceeds the internal limit of "+Integer.MAX_VALUE);
          }
          int sn = sig2scope(s);
          if (sn<0) {
             if (missing!=null) continue;
             sig2scope(s, sum);
View Full Code Here

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

    private boolean derive_overall_scope (Iterable<Sig> sigs) throws Err {
        boolean changed=false;
        final int overall = (cmd.overall<0 && cmd.scope.size()==0) ? 3 : cmd.overall;
        for(Sig s:sigs) if (!s.builtin && s.isTopLevel() && sig2scope(s)<0) {
            if (s.isEnum!=null) { sig2scope(s, 0); continue; } // enum without children should get the empty set
            if (overall<0) throw new ErrorSyntax(cmd.pos, "You must specify a scope for sig \""+s+"\"");
            sig2scope(s, overall);
            changed=true;
        }
        return changed;
    }
View Full Code Here

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

           int pb = sig2scope(p);
           if (pb>=0) {sig2scope(s,pb); changed=true;} else {trouble=s;}
        }
        if (changed) return true;
        if (trouble==null) return false;
        throw new ErrorSyntax(cmd.pos,"You must specify a scope for sig \""+trouble+"\"");
    }
View Full Code Here

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

        // Process each sig listed in the command
        for(CommandScope entry:cmd.scope) {
            Sig s = entry.sig;
            int scope = entry.startingScope;
            boolean exact = entry.isExact;
            if (s==UNIV) throw new ErrorSyntax(cmd.pos, "You cannot set a scope on \"univ\".");
            if (s==SIGINT) throw new ErrorSyntax(cmd.pos,
                    "You can no longer set a scope on \"Int\". "
                    +"The number of atoms in Int is always exactly equal to 2^(integer bitwidth).\n");
            if (s==SEQIDX) throw new ErrorSyntax(cmd.pos,
                    "You cannot set a scope on \"seq/Int\". "
                    +"To set the maximum allowed sequence length, use the seq keyword.\n");
            if (s==STRING) {
               if (maxstring>=0) throw new ErrorSyntax(cmd.pos, "Sig \"String\" already has a scope of "+maxstring+", so we cannot set it to be "+scope);
               if (!exact) throw new ErrorSyntax(cmd.pos, "Sig \"String\" must have an exact scope.");
               maxstring = scope;
               continue;
            }
            if (s==NONE) throw new ErrorSyntax(cmd.pos, "You cannot set a scope on \"none\".");
            if (s.isEnum!=null) throw new ErrorSyntax(cmd.pos, "You cannot set a scope on the enum \""+s.label+"\"");
            if (s.isOne!=null && scope!=1) throw new ErrorSyntax(cmd.pos,
                "Sig \""+s+"\" has the multiplicity of \"one\", so its scope must be 1, and cannot be "+scope);
            if (s.isLone!=null && scope>1) throw new ErrorSyntax(cmd.pos,
                "Sig \""+s+"\" has the multiplicity of \"lone\", so its scope must 0 or 1, and cannot be "+scope);
            if (s.isSome!=null && scope<1) throw new ErrorSyntax(cmd.pos,
                "Sig \""+s+"\" has the multiplicity of \"some\", so its scope must 1 or above, and cannot be "+scope);
            sig2scope(s, scope);
            if (exact) makeExact(cmd.pos, s);
        }
        // Force "one" sigs to be exactly one, and "lone" to be at most one
View Full Code Here

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

        //    you will go into an infinite loop (since, regardless of the instantiating parameter,
        //    that file will attempt to OPEN the exact same set of files. leading back to itself, etc. etc.)
        // <= If there is an infinite loop, that means there is at least 1 infinite chain of OPEN (from root).
        //    Since the number of files is finite, at least 1 filename will be repeated.
        if (thispath.contains(filename))
           throw new ErrorSyntax(pos,
           "Circular dependency in module import. The file \""+(new File(filename)).getName()+"\" is imported infinitely often.");
        thispath.add(filename);
        // No cycle detected so far. So now we parse the file.
        CompModule u = CompParser.alloy_parseStream(seenDollar, loaded, fc, root, 0, filename, prefix, initialResolution);
        if (prefix.length()==0) root = u;
        // Here, we recursively open the included files
        for(Open x: u.getOpens()) {
            String cp=Util.canon(computeModulePath(u.getModelName(), filename, x.filename)), content=fc.get(cp);
            try {
                if (content==null) { content=loaded.get(cp); }
                if (content==null) { content=fc.get(x.filename);     if (content!=null) cp=x.filename; }
                if (content==null) { content=loaded.get(x.filename); if (content!=null) cp=x.filename; }
                if (content==null) { content=Util.readAll(cp); }
            } catch(IOException ex1) {
                try {
                    String newCp = (Util.jarPrefix()+"models/"+x.filename+".als").replace('/', File.separatorChar);
                    content = Util.readAll(newCp);
                    cp = newCp;
                } catch(IOException ex) {
                    throw new ErrorSyntax(x.pos,
                    "This module cannot be found.\nIt is not a built-in library module, and it cannot be found at \""+cp+"\".\n");
                }
            }
            loaded.put(cp, content);
            CompModule y = parseRecursively(seenDollar, loaded, fc, x.pos, cp, root, (prefix.length()==0 ? x.alias : prefix+"/"+x.alias), thispath, initialResolution);
View Full Code Here

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, 1);
            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
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.