Search in sources :

Example 1 with ConstExpression

use of org.whole.lang.scheme.model.ConstExpression in project whole by wholeplatform.

the class SchemeInterpreterVisitor method visit.

public void visit(ApplyExpression entity) {
    IEntity exprs = entity.getExpressions();
    if (!exprs.wGetEntityDescriptor().equals(SchemeEntityDescriptorEnum.SchemeExpressions))
        throw new VisitException("expected a " + SchemeEntityDescriptorEnum.SchemeExpressions);
    if (exprs.wIsEmpty())
        throw new VisitException("empty application");
    ConstExpression head = (ConstExpression) evaluate((SchemeExpression) exprs.wGet(0));
    ConstExpression[] args = new ConstExpression[exprs.wSize() - 1];
    for (int i = 1; i < exprs.wSize(); i++) args[i - 1] = (ConstExpression) evaluate(((SchemeExpression) exprs.wGet(i)));
    apply(head, args);
}
Also used : ConstExpression(org.whole.lang.scheme.model.ConstExpression) IEntity(org.whole.lang.model.IEntity) SchemeExpression(org.whole.lang.scheme.model.SchemeExpression) VisitException(org.whole.lang.visitors.VisitException)

Aggregations

IEntity (org.whole.lang.model.IEntity)1 ConstExpression (org.whole.lang.scheme.model.ConstExpression)1 SchemeExpression (org.whole.lang.scheme.model.SchemeExpression)1 VisitException (org.whole.lang.visitors.VisitException)1