package de.dhbwstuttgart.syntaxtree;

import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;

public class ExpressionPattern extends Pattern {
    private final Expression expression;

    public ExpressionPattern(Expression expression, Token offset) {
        super(expression.getType(), offset);
        this.expression = expression;
    }

    public Expression getExpression() {
        return expression;
    }

    @Override
    public void accept(ASTVisitor visitor) {
        visitor.visit(this);
    }

    @Override
    public ExpressionPattern withType(RefTypeOrTPHOrWildcardOrGeneric type) {
        return new ExpressionPattern(expression, getOffset());
    }
}
