Skip to main content

xsd_schema/xpath/ast/
core.rs

1// ============================================================================
2// Core AST Node Enum
3// ============================================================================
4
5use super::{
6    BinaryOpNode, ContextItemNode, ExprNode, FilterExprNode, ForNode, FunctionCallNode, IfNode,
7    PathExprNode, PathStepNode, QuantifiedNode, RangeNode, TypeExprNode, UnaryOpNode, ValueNode,
8    VarRefNode,
9};
10
11/// The main AST node type, encompassing all possible expression types.
12#[derive(Debug, Clone)]
13pub enum AstNode {
14    /// Comma-separated sequence of expressions.
15    Expr(ExprNode),
16    /// Literal value (string, number, boolean, empty).
17    Value(ValueNode),
18    /// Context item reference (`.`).
19    ContextItem(ContextItemNode),
20    /// Variable reference (`$name`).
21    VarRef(VarRefNode),
22    /// Conditional expression (`if ... then ... else`).
23    If(IfNode),
24    /// For expression (`for $x in ... return`).
25    For(ForNode),
26    /// Quantified expression (`some`/`every ... satisfies`).
27    Quantified(QuantifiedNode),
28    /// Function call (`name(...)`).
29    FunctionCall(FunctionCallNode),
30    /// Path expression (absolute or relative).
31    PathExpr(PathExprNode),
32    /// Filter expression (`expr[predicate]`).
33    FilterExpr(FilterExprNode),
34    /// Range expression (`expr to expr`).
35    Range(RangeNode),
36    /// Unary operator (`+` or `-`).
37    UnaryOp(UnaryOpNode),
38    /// Binary operator (arithmetic, comparison, logical, etc.).
39    BinaryOp(BinaryOpNode),
40    /// Single path step (axis + node test + predicates).
41    PathStep(PathStepNode),
42    /// Type expression (instance of, treat as, cast as, castable as).
43    TypeExpr(TypeExprNode),
44}