Package edu.mit.csail.sdg.alloy4

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


            if (array[0].equals("warnings")) {
                if (warnings.size()==0) span.setLength(len2);
                else if (warnings.size()>1) span.logBold("Note: There were "+warnings.size()+" compilation warnings. Please scroll up to see them.\n\n");
                else span.logBold("Note: There was 1 compilation warning. Please scroll up to see them.\n\n");
                if (warnings.size()>0 && Boolean.FALSE.equals(array[1])) {
                   Pos e = warnings.iterator().next().pos;
                   gui.doVisualize("POS: "+e.x+" "+e.y+" "+e.x2+" "+e.y2+" "+e.filename);
                   span.logBold("Warnings often indicate errors in the model.\n"
                     +"Some warnings can affect the soundness of the analysis.\n"
                     +"To proceed despite the warnings, go to the Options menu.\n");
                }
            }
            if (array[0].equals("warning")) {
                ErrorWarning e = (ErrorWarning)(array[1]);
                if (!warnings.add(e)) return;
                Pos p=e.pos;
                span.logLink("Warning #"+warnings.size(), "POS: "+p.x+" "+p.y+" "+p.x2+" "+p.y2+" "+p.filename);
                span.log("\n"); span.logIndented(e.msg.trim()); span.log("\n\n");
            }
            if (array[0].equals("sat")) {
                boolean chk = Boolean.TRUE.equals(array[1]);
View Full Code Here


    //============================================================================================================//

    /** {@inheritDoc} */
    @Override public Pos span() {
        Pos p=span;
        if (p==null) {
            p=pos.merge(closingBracket);
            for(Expr a:args) p=p.merge(a.span());
            span=p;
        }
        return p;
    }
View Full Code Here

    @Override public List<? extends Browsable> getSubnodes() {
        if (args.size()==0) {
            Expr b = fun.getBody();
            return Util.asList(make(b.pos(), b.span(), b.getDescription(), b.getSubnodes()));
        }
        Pos p = pos;
        if (p == Pos.UNKNOWN) p = span();
        Browsable f = make(p, p, (fun.isPred ? "<b>pred</b> " : "<b>fun</b> ")+fun.label , fun.getSubnodes());
        Browsable a = make(span(), span(), "<b>" + args.size() + " argument" + (args.size()==1 ? "</b>" : "s</b>"), args);
        return Util.asList(f, a);
    }
View Full Code Here

    //============================================================================================================//

    /** {@inheritDoc} */
    @Override public Pos span() {
        Pos p=span;
        if (p==null) {
            p=pos.merge(closingBracket);
            for(Expr a:args) p=p.merge(a.span());
            span=p;
        }
        return p;
    }
View Full Code Here

    /** Caches the span() result. */
    private Pos span = null;

    /** {@inheritDoc} */
    @Override public Pos span() {
        Pos p = span;
        if (p==null) span = (p = cond.span().merge(right.span()).merge(left.span()));
        return p;
    }
View Full Code Here

        try { throw new Exception(); } catch(Exception ex) { name = ex.getStackTrace()[1].getMethodName(); }
        Method[] methods = getClass().getDeclaredMethods();
        Method m=null;
        for(int i=0; i<methods.length; i++) if (methods[i].getName().equals(name)) { m=methods[i]; break; }
        final Method method=m;
        return new Runner() {
            private static final long serialVersionUID = 0;
            public void run() {
                try {
                    method.setAccessible(true);
                    method.invoke(SimpleGUI.this, new Object[]{});
View Full Code Here

        try { throw new Exception(); } catch(Exception ex) { name = ex.getStackTrace()[1].getMethodName(); }
        Method[] methods = getClass().getDeclaredMethods();
        Method m=null;
        for(int i=0; i<methods.length; i++) if (methods[i].getName().equals(name)) { m=methods[i]; break; }
        final Method method=m;
        return new Runner() {
            private static final long serialVersionUID = 0;
            public void run(Object arg) {
                try {
                    method.setAccessible(true);
                    method.invoke(SimpleGUI.this, new Object[]{arg});
View Full Code Here

    /** Parse sig/set. */
    private Sig parseSig(String id, int depth) throws IOException, Err {
        Sig ans = id2sig.get(id);
        if (ans!=null) return ans;
        XMLNode node = nmap.get(id);
        if (node==null) throw new IOException("Unknown SigID "+id+" encountered.");
        if (!node.is("sig")) throw new IOException("ID "+id+" is not a sig.");
        String label   = label(node);
        Attr isAbstract = yes(node,"abstract") ? Attr.ABSTRACT : null;
        Attr isOne      = yes(node,"one")      ? Attr.ONE      : null;
        Attr isLone     = yes(node,"lone")     ? Attr.LONE     : null;
        Attr isSome     = yes(node,"some")     ? Attr.SOME     : null;
        Attr isPrivate  = yes(node,"private"? Attr.PRIVATE  : null;
        Attr isMeta     = yes(node,"meta")     ? Attr.META     : null;
        Attr isEnum     = yes(node,"enum")     ? Attr.ENUM     : null;
        Attr isExact    = yes(node,"exact")    ? Attr.EXACT    : null;
        if (yes(node,"builtin")) {
           if (label.equals(UNIV.label))   { id2sig.put(id, UNIV);   return UNIV;   }
           if (label.equals(SIGINT.label)) { id2sig.put(id, SIGINT); return SIGINT; }
           if (label.equals(SEQIDX.label)) { id2sig.put(id, SEQIDX); return SEQIDX; }
           if (label.equals(STRING.label)) { id2sig.put(id, STRING); return STRING; }
           throw new IOException("Unknown builtin sig: "+label+" (id="+id+")");
        }
        if (depth > nmap.size()) throw new IOException("Sig "+label+" (id="+id+") is in a cyclic inheritance relationship.");
        List<Sig> parents = null;
        TupleSet ts = factory.noneOf(1);
        for(XMLNode sub:node) {
           if (sub.is("atom")) { ts.add(factory.tuple(sub.getAttribute("label"))); continue; }
           if (!sub.is("type")) continue;
           Sig parent = parseSig(sub.getAttribute("ID"), depth+1);
           if (parents==null) parents = new ArrayList<Sig>();
           parents.add(parent);
        }
        if (parents==null) {
           String parentID = node.getAttribute("parentID");
           Sig parent = parseSig(parentID, depth+1);
           if (!(parent instanceof PrimSig)) throw new IOException("Parent of sig "+label+" (id="+id+") must not be a subset sig.");
           for(Expr choice: choices)
              if (choice instanceof PrimSig && parent==((PrimSig)choice).parent && ((Sig)choice).label.equals(label))
                 { ans=(Sig)choice; choices.remove(choice); break; }
View Full Code Here

        return expr;
    }

    /** Parse field. */
    private Field parseField(String id) throws IOException, Err {
       final XMLNode node = nmap.get(id);
       if (node==null) throw new IOException("Unknown FieldID "+id+" encountered.");
       if (!node.is("field")) throw new IOException("ID "+id+" is not a field.");
       String label  = label(node);
       Pos isPrivate = yes(node,"private") ? Pos.UNKNOWN : null;
       Pos isMeta = yes(node,"meta") ? Pos.UNKNOWN : null;
       Expr type = null;
       for(XMLNode sub:node) if (sub.is("types")) { Expr t=parseType(sub); if (type==null) type=t; else type=type.plus(t); }
       int arity;
       if (type==null || (arity=type.type().arity())<2) throw new IOException("Field "+label+" is maltyped.");
       String parentID = node.getAttribute("parentID");
       Sig parent = id2sig.get(parentID);
       if (parent==null) throw new IOException("ID "+parentID+" is not a sig.");
       Field field = null;
       for(Field f: parent.getFields())
           if (f.label.equals(label) && f.type().arity()==arity && choices.contains(f))
View Full Code Here

       return field;
    }

    /** Parse skolem. */
    private ExprVar parseSkolem(String id) throws IOException, Err {
       final XMLNode node = nmap.get(id);
       if (node==null) throw new IOException("Unknown ID "+id+" encountered.");
       if (!node.is("skolem")) throw new IOException("ID "+id+" is not a skolem.");
       String label = label(node);
       Expr type = null;
       for(XMLNode sub:node) if (sub.is("types")) { Expr t=parseType(sub); if (type==null) type=t; else type=type.plus(t); }
       int arity;
       if (type==null || (arity=type.type().arity())<1) throw new IOException("Skolem "+label+" is maltyped.");
View Full Code Here

TOP

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

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.