001package gudusoft.gsqlparser.ir.logical;
002
003import gudusoft.gsqlparser.ir.common.SourceAnchor;
004
005/**
006 * Base class for all expression nodes in the Logical IR.
007 * <p>
008 * Immutable after construction. Traversal must be iterative (no recursion).
009 */
010public abstract class RexNode {
011
012    public enum RexKind {
013        COLUMN_REF,
014        LITERAL,
015        CALL,
016        PARAM_REF,
017        SUBQUERY,
018        WILDCARD,
019        CAST
020    }
021
022    private final RexKind kind;
023    private final SourceAnchor anchor;
024
025    protected RexNode(RexKind kind, SourceAnchor anchor) {
026        this.kind = kind;
027        this.anchor = anchor;
028    }
029
030    public RexKind getKind() { return kind; }
031    public SourceAnchor getAnchor() { return anchor; }
032
033    public abstract <R> R accept(RexNodeVisitor<R> visitor);
034
035    @Override
036    public String toString() {
037        return kind.name();
038    }
039}