Search in sources :

Example 16 with VisitException

use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.

the class GenericMatcherFactory method isPlatformSubtypeOfMatcher.

@Deprecated
public IVisitor isPlatformSubtypeOfMatcher(String edUri) {
    return new AbstractEntityDescriptorBasedMatcher(edUri) {

        public void visit(IEntity entity) {
            EntityDescriptor<?> ed = entity.wGetEntityDescriptor();
            EntityDescriptor<?> otherEd = getOtherEntityDescriptor(ed);
            if (otherEd == null || !otherEd.isPlatformSupertypeOf(ed))
                throw new VisitException();
        }

        protected String predicateName() {
            return "isPlatformSubtypeOf";
        }
    };
}
Also used : IEntity(org.whole.lang.model.IEntity) VisitException(org.whole.lang.visitors.VisitException)

Example 17 with VisitException

use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.

the class GenericMatcherFactory method isLanguageSupertypeOfMatcher.

public IVisitor isLanguageSupertypeOfMatcher(String edUri) {
    return new AbstractEntityDescriptorBasedMatcher(edUri) {

        public void visit(IEntity entity) {
            EntityDescriptor<?> entityEd = entity.wGetEntityDescriptor();
            EntityDescriptor<?> ed = getOtherEntityDescriptor(entityEd);
            if (ed == null || !entityEd.isLanguageSupertypeOf(ed))
                throw new VisitException();
        }

        protected String predicateName() {
            return "isLanguageSupertypeOf";
        }
    };
}
Also used : IEntity(org.whole.lang.model.IEntity) VisitException(org.whole.lang.visitors.VisitException)

Example 18 with VisitException

use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.

the class GenericMatcherFactory method hasKindMatcher.

public IVisitor hasKindMatcher(final EntityKinds kind) {
    return new AbstractVisitor() {

        public void visit(IEntity entity) {
            if (!kind.equals(entity.wGetEntityKind()))
                throw new VisitException();
        }

        public void toString(StringBuilder sb) {
            sb.append("hasKind(");
            sb.append(kind);
            sb.append(")");
        }
    };
}
Also used : AbstractVisitor(org.whole.lang.visitors.AbstractVisitor) IEntity(org.whole.lang.model.IEntity) VisitException(org.whole.lang.visitors.VisitException)

Example 19 with VisitException

use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.

the class SchemeInterpreterVisitor method visit.

public void visit(AndExpression entity) {
    IEntity exprs = entity.getExpressions();
    if (!exprs.wGetEntityDescriptor().equals(SchemeEntityDescriptorEnum.SchemeExpressions))
        throw new VisitException("expected a " + SchemeEntityDescriptorEnum.SchemeExpressions);
    boolean result = true;
    for (int i = 0; i < exprs.wSize(); i++) result = result && booleanValue(((SchemeExpression) exprs.wGet(i)));
    setResult(SchemeEntityFactory.instance.createBooleanValue(result));
}
Also used : IEntity(org.whole.lang.model.IEntity) VisitException(org.whole.lang.visitors.VisitException)

Example 20 with VisitException

use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.

the class SchemeInterpreterVisitor method visit.

public void visit(LocalExpression entity) {
    getBindings().wEnterScope();
    Definitions defs = entity.getDefinitions();
    if (!defs.wGetEntityDescriptor().equals(SchemeEntityDescriptorEnum.Definitions))
        throw new VisitException("expected a " + SchemeEntityDescriptorEnum.Definitions);
    for (int i = 0; i < defs.wSize(); i++) {
        IEntity e = defs.wGet(i);
        if (e.wGetEntityDescriptor().equals(SchemeEntityDescriptorEnum.Definition)) {
            Definition def = ((Definition) e);
            getBindings().wDef(def.getName().wStringValue(), def.getExpression());
        }
    }
    entity.getBody().accept(this);
    getBindings().wExitScope();
}
Also used : IEntity(org.whole.lang.model.IEntity) Definitions(org.whole.lang.scheme.model.Definitions) VisitException(org.whole.lang.visitors.VisitException) Definition(org.whole.lang.scheme.model.Definition)

Aggregations

VisitException (org.whole.lang.visitors.VisitException)35 IEntity (org.whole.lang.model.IEntity)25 IBindingManager (org.whole.lang.bindings.IBindingManager)6 File (java.io.File)4 AbstractVisitor (org.whole.lang.visitors.AbstractVisitor)4 HashSet (java.util.HashSet)3 GenericIdentityVisitor (org.whole.lang.visitors.GenericIdentityVisitor)3 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 PrettyPrinterOperation.toPrettyPrintString (org.whole.lang.operations.PrettyPrinterOperation.toPrettyPrintString)2 GenericTraversalFactory (org.whole.lang.visitors.GenericTraversalFactory)2 IVisitor (org.whole.lang.visitors.IVisitor)2 EvalError (bsh.EvalError)1 Interpreter (bsh.Interpreter)1 BufferedReader (java.io.BufferedReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 Writer (java.io.Writer)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1